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
我希望结果是
id - name - notes
1 - ric - abcdef
2 - joe -
3 - harry-
4 - james- xyzzz
答案 0 :(得分:2)
SELECT t1.id, t1.name, t2.notes
FROM Table1 t1
LEFT OUTER JOIN Table2 t2 ON t1.id = t2.Tbl_1_Id
答案 1 :(得分:2)
使用左连接。
SELECT t1.id, t1.name, t2.notes FROM
table1 as t1
LEFT JOIN table2 as t2 ON (t1.id = t2.tbl_1_id)