需要使用SQL查询
问题描述:
Table 1
id - name
1 - ric
2 - joe
3 - harry
4 - james
Table 2
sno - Tbl_1_Id - notes
1 - 1 - abcdef
2 - 4 - xyzzz
我需要帮助的结果是需要使用SQL查询
id - name - notes
1 - ric - abcdef
2 - joe -
3 - harry-
4 - james- xyzzz
答
SELECT t1.id, t1.name, t2.notes
FROM Table1 t1
LEFT OUTER JOIN Table2 t2 ON t1.id = t2.Tbl_1_Id
答
使用左连接。
SELECT t1.id, t1.name, t2.notes FROM
table1 as t1
LEFT JOIN table2 as t2 ON (t1.id = t2.tbl_1_id)