如何把sql查询出来的结果当做另一个sql的条件查询

如题所述

-- table2 的 name 作为 table1的条件
select * from table1 where name in (select name from table2)

--如果有多条语句,可以使用字段相加再等于
select * from table1 where fld1+fld2 in (select fld1+fld2 from table2)

--也可以使用INNER JOIN 进行查询
select a.* from table1 a inner join (select name from table2 group by name) b on a.name=b.name

温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2017-06-30

嵌套查询就可以实现了,比如:

select * from (select col from table) t where t.col='1';

本回答被网友采纳
相似回答