我有一个简单的查询,
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
我有一个简单的查询,
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
select a.* from myTableA a join myTableB b on a.ID = B.ID
这是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)
select a.ID,
a.Value,
a.Fruit
from myTableA a join myTableB b on a.ID = B.ID
像这样取消选择 b
SELECT a.* from myTableA a left join myTableB b on a.ID=b.ID