查询在一个相关的表中不存在的数据,如用户表(user)和用户资料表(user_profile),通过id关联,要查出user表中在user_profile中不存在的记录:
select count(*) from?user left join?user_profile On user.id=user_profile.id where user_profile.id is null
复杂条件:
select count(*) from?user left join?user_profile On user.id=user_profile.id where user.level>1 or user_profile.money>10000
博客介绍了在相关表中查询不存在数据的方法,以用户表和用户资料表为例,通过id关联,给出了查出user表中在user_profile中不存在记录的SQL语句,还提及了复杂条件下的查询语句。

2万+

被折叠的 条评论
为什么被折叠?



