可以存在两种写法:
例一:
select * from
AA as a,
BB as b
where
a.id = b.id
// 也可以增加a表的查询条件,以及b表的查询条件
and a.name = 'aqiang'
and b.age = '18'
例二:
select * from
A
where
name = 'aqiang'
and
bid in (
select id from
B
and age = 18
)
两种情况查询出来的数量相同:但是查询时间不同,经过验证例一代码块的运行时间比例二代码块的运行时间要快,所以推荐使用例一,还有一种情况没有写就是使用连接的方式,此方式对于性能要求比较大,故所以不推荐使用连接的方式。