in(): sql子查询 , 返回一个集合,所查集合包含在条件中。
例:select * from table_name1 as t
where t.name in(
select t2.name from table_name2 as t2
)
and t.number = 1000
解释:查询 table_name1表 中 name包含 table_name2表 name 的数据 ,并且在table_name1表中number=1000的数据
例2:select * from table_name1 as t
where t.name in("AAA","BBB")
and t.number = 1000
解释:查询出table_name1中 t.name包含 "AAA"和"BBB" ,并且在table_name1表中number=1000的数据
例3:select * from table_name1 as t
where t.name in(
select t2.name from table_name2 as t2
)
and t.age in(
select t2.age from table_name2 as t2
)
and t.number = 1000