第二种,in,not in的用法 select * from table1 where columnName in(select columnName from table2 where columnNane = 'condition')第三种,any,all与比较运算的用法 -- 与任意一个比较返回真 select * from table1 where columnName > any(select columnName from table2 where columnNane ...
mysql主表查询的where 条件怎么写查询另一个表的数据?
后面写一个 字段 in (select from 另一个表)2017-06-29
第一种 exists与not exists
select * from table1 t1 where exists(select columnName from table2 t2 where t1.columnName2 = t2.columnName2)
第二种,in,not in的用法
select * from table1 where columnName in(select columnName from table2 where columnNane = 'condition')
第三种,any,all与比较运算的用法
-- 与任意一个比较返回真
select * from table1 where columnName > any(select columnName from table2 where columnNane = 'condition')
-- 与所有的值比较返回真
select * from table1 where columnName > all(select columnName from table2 where columnNane = 'condition')2017-06-29