Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张包含大量数据的表,我想从这张表中选择所有内容。
另一个表包含不同的状态码(字段ID和text),我想将此表加入第一个表,所以我得到类似
ID
text
来自第一个表id1,text2,id2,text2或id1,id2,text1,text2第二个表的所有数据。
id1,text2,id2,text2
id1,id2,text1,text2
利用LEFT OUTER JOIN
LEFT OUTER JOIN
Select T1.*,T2.ID,T2.Text from firstTable t1 LEFT OUTER JOIN SecondTable T2 on T1.<col>=T2.<col>
无论是左/右/内连接,您都可以像这样使用连接
SELECT t1.*,t2.id,t2.text FROM table1 t1 LEFT JOIN table2 t2 ON t2.column_name=t1.column_name