A表有两个字段 id,bID. 其中bID,是b表的主键
B表有两个字段 id,bName.
问现在如何才查训条件中输入bName的时候能将与a相关的结果都带出来,并且只能使用单表查询,不能使用外键
*B表的name,是可以出现重复的数据的
好久没有写过了,不知道对不对,逻辑应该没问题
select A.id,A.bID from table A where A.bID = (selsct id from B where bName = 'zhangsan')
select t1.* t2.* from table t1, table t2 where t1.id = t2.bID
select a.*,b.* from a inner join b on a.id=b.id
只能使用单表查询?不知道我理解的对不对哈, 我觉得你可以建个视图 create view ab as select ta.id aid,tb.id bid,tb.name bname from b tb left join a ta on tb.id = ta.bid
select * from a ta where exists select id from b tb where ta.bid = tb.id and tb.name = '???' 或者这样?
完全外连接:select * from a full join b on a.id=b.id
select A.column1,A.column2, B.columnN ,C.columnN from tableA inner join tableB on tableB.** = tableA.*** inner join tableC on table A.**= tableC.**