我有两个表加入以显示项目列表,目前它就是这样的。
SELEC tableA.item1,tableA.item2,tableB.item3,tableB.item 4,tableA.item5 FROM tableA INNER JOIN tableB ON tableA.item2 = tableB.item1 WHERE tableA.item1 = A
并且显示如下
item1 item2 item3 item4 Item5
A Z 1 0.1 B1
A Y 2 0.2 B2
A X 3 0.3 B3
但是我希望它显示一列,例如item1,以显示tableA中的所有项目。比如像这样
item1 item2 item3 item4 item5
A Z 1 0.1 B1
A Y 2 0.2 B2
A X 3 0.3 B3
W
V
U
像这样的东西。有没有像SELECT * item1,item2 FROM tableA等
的方法答案 0 :(得分:0)
使用LEFT OUTER JOIN而不是INNER JOIN来获取tableA中没有匹配的tableA中的项目。
答案 1 :(得分:0)
您是否尝试过Union
?
SELECT tableA.item1, tableA.item2, tableB.item3, tableB.item 4, tableA.item5 FROM tableA INNER JOIN tableB ON tableA.item2 = tableB.item1 WHERE tableA.item1 = A
UNION
SELECT NULL as item1, item2, NULL as item3, NULL as item 4, NULL as item5 FROM tableA