Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 SQL查询基于对2个表的引用从第二个表中提取列值_Sql Server 2008 - Fatal编程技术网

Sql server 2008 SQL查询基于对2个表的引用从第二个表中提取列值

Sql server 2008 SQL查询基于对2个表的引用从第二个表中提取列值,sql-server-2008,Sql Server 2008,抱歉,我试图搜索答案,结果被卡住了 我正在尝试将两个表内部连接以获取一个值,例如 table 1 -------- column a column b column c table 2 -------- column a column d 因此,我想从表1中提取所有列,然后,在表2中出现列a的地方,我想提取列d 只是不确定内部联接是否正确或如何写入它有四种联接类型: JOIN: Return rows when there is at least one match in both tabl

抱歉,我试图搜索答案,结果被卡住了

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

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

table 2
--------
column a
column d
因此,我想从
表1
中提取所有列,然后,在
表2中出现
列a
的地方,我想提取
列d


只是不确定内部联接是否正确或如何写入它有四种联接类型:

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
如所列

您希望从描述中使用左连接

SELECT table1.*, table2.d FROM table1 LEFT JOIN table2 ON table1.a = table2.a
select table1.*, table2.d from table1 left join table2 on table1.a = table2.a