您的位置:首页 > 数据库 > MySQL

Mysql中左连接的使用

2004-08-25 16:43 781 查看
查询在一个相关的表中不存在的数据,如用户表(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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql user null