打印本文 打印本文 关闭窗口 关闭窗口
Mysql中左连接的使用
作者:武汉SEO闵涛  文章来源:敏韬网  点击数768  更新时间:2009/4/22 20:14:21  文章录入:mintao  责任编辑:mintao
查询在一个相关的表中不存在的数据,如用户表(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

打印本文 打印本文 关闭窗口 关闭窗口