SELECT A.id, A.name, C.name FROM A INNER JOIN B ON A.id=B.id INNER JOIN A AS C ON B.b_id=C.id
没有读懂题目的意思,能否将题目再详尽的说明一下。
name2是表B的字段么
话说那个name2是哪来的……
如果name2是从B表来的话
select A.id,A.name,B.name2
from A,B
where A.id = B.id
union all
select null,null,name2
from B
where B.id not in (select id from A)