2

抱歉,我尝试寻找答案并卡住了

我正在尝试内部连接两个表以提取一个值,例如

table 1
--------
column a
column b
column c

table 2
--------
column a
column d

所以,我想从中拉出所有列table 1,然后在column a出现的地方table 2,我想拉column d

只是不确定内部连接是否正确或如何编写

4

2 回答 2

3

有四种类型的连接:

JOIN: Return rows when there is at least one match in both tables
LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
FULL JOIN: Return rows when there is a match in one of the tables

如http://www.w3schools.com/sql/sql_join.asp上所列

您想从描述中获得 LEFT JOIN

SELECT table1.*, table2.d FROM table1 LEFT JOIN table2 ON table1.a = table2.a
于 2013-05-01T16:30:19.207 回答
0
select table1.*, table2.d from table1 left join table2 on table1.a = table2.a
于 2013-05-01T16:30:42.623 回答