条件查询:
-- 查询name = '测试' 或 email="test.com" 和id=1 select * from db where (name = '测试' or email="test.com") and id=1; -- 查找id在(1,2,3) select * from db where id in (1,2,3); -- 查找id在user表中的数据 select * from db where id in (select id from user); -- 查找uer表id=5的语句是否存在,不存在则不查询db表 select * from db where exists (select * from user where id=5); -- 查找uer表id=5的语句是否不存在,不存在则查询db表 select * from db where not exists (select * from user where id=5); -- 查找db表中id大于2的数据且age大于5的数据 select * from (select * from db where id>2) as T where as.age > 5;