sql select id from a where id=(select id from b where id=(select id from c where name=✀aaaaa✀))

2025-04-28 07:16:03
推荐回答(3个)
回答1:

如果A表中id是主键,只想返回一个结果,用inner join 的话,结果可能是多个行,不符合要求
用exists
sql select a.id from a
where exists

select 1 from b
inner join c
on b.id=c.id
where c.name='aaaaa'
and a.id = b.id

回答2:

sql select id from a where id=(select id from b where id=(select id from c where name='aaaaa'))
改成inner join
sql select a.id from a
inner join b
on a.id=b.id
inner join c
on b.id=c.id
where c.name='aaaaa'

回答3:

这肯定要用关联查询吧,没这样写过,前两个=都换成in呢