0

我有一个简单的查询,

select a.*,b.* from myTableA a join myTableB b on a.ID = B.ID

这很好用。但是,它显示为

ID|Value|Fruit|ID1|Value1|Fruit1

我如何得到结果

ID|Value|Fruit
1|A|Apple
1|B|Mango

4

4 回答 4

0
select a.* from myTableA a join myTableB b on a.ID = B.ID
于 2012-04-06T13:15:49.063 回答
0

这是UNION您正在描述的查询:

SELECT ID, Value, Fruit
FROM myTableA
WHERE ID IN (SELECT B.ID FROM myTableB B)
UNION ALL
SELECT ID, Value, Fruit
FROM myTableB
WHERE ID IN (SELECT A.ID FROM myTableA A)
于 2012-04-06T13:16:27.810 回答
0
select a.ID,
a.Value,
a.Fruit
from myTableA a join myTableB b on a.ID = B.ID
于 2012-04-06T13:17:00.603 回答
0

像这样取消选择 b

SELECT a.* from myTableA a left join myTableB b on a.ID=b.ID
于 2012-04-06T13:18:02.573 回答