表A有,id,tno,name B表有id,bno,name,C表有id,aid,bid.要求找出所有A表中和B表中ID关联的记录,取出表A中的所有记录,和B表没有关联的提示未关联,这条SQL如何写才好些
select a.* from A a,C c
where a.id=c.aid
select a.* from A a,C c
where a.id<>c.aid
怎样更好的把这两条SQL拿到一起,得出A表中所有记录的同时知道那些已关联那些未关联
1.select a.*,(case when b.id is null then '未关联'else '关联' end) from A a,B b
where a.id=b.id(+)
2.select a.*, 相同 from A a,C c
where a.id=c.aid
union all
select a.*, 不相同 from A a,C c
where a.id<>c.aid
3.select a.id,a.tno,a.name,b.bno,b.name
from b outer join a on
(a.id=c.id and b.id=c.id)
outer前加left 。请大家指教......