SQL列名称句点(。)*

时间:2015-07-29 23:13:58

标签: sql

我阅读了以下查询:

SELECT result.* FROM 
(SELECT *
FROM t1
JOIN t2
ON t1.num = t2.num) AS result;

什么是SELECT a.* FROM my_table AS a JOIN your_table AS b ON ... 以及它的意思/做什么?

1 个答案:

答案 0 :(得分:3)

表示“表a中的所有列”,在您的示例中引用my_table

如果您想要特定的列,可以执行以下操作:

SELECT a.columnName, a.anotherColumn FROM my_table AS a JOIN your_table AS b ON ...

如果您想要ab中的所有列,请执行以下操作:

SELECT a.*, b.* FROM my_table AS a JOIN your_table AS b ON ...

或者如果你想要一些来自a,而所有来自b:

SELECT a.columnName, a.anotherColumn, b.* FROM my_table AS a JOIN your_table AS b ON ...