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
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 Connector Net连接MySQL使用正确的连接字符串
- 为MySQL Connector Net连接MySQL使用正确的连接字符串
- Tomcat6.0使用jdbc连接池连接mysql--操作步骤介绍
- MySQL连接8小时未使用连接失效的处理方法
- 解决 c3p0 和 MySQL 集成情况下,连接长时间闲置后重新使用时报错的问题
- 使用了星外的Ipsec如何允许MySQL远程连接?
- 使用连接(JOIN)来代替子查询(Sub-Queries) mysql优化系列记录
- 使用TOMCAT5.5连接池连接mysql(解决Cannot create JDBC driver of class '' for connect URL 'null')
- 解决使用MySQL C-API开发应用时的连接超时问题
- 你还在使用mysql_connect()连接MySQL吗?
- Mysql授权root用户使用远程客户端连接
- 使用TOMCAT5.5连接池连接mysql(解决Cannot create JDBC driver of class '' for connect URL 'null' 及can not load org.gjt.mm.mysql.Driver)
- JSP连接MySQL配置与使用
- 使用BDC连接MySql可能遇到的问题
- 使用hibernate连接mysql自动中断的问题
- 转帖:使用BDC连接MySql可能遇到的问题
- 使用JDBC连接MySql
- java.net.SocketException: Broken pipe /Mysql在经过8小时不使用后会自动关闭已打开的连接
- 为MySQL Connector Net连接MySQL使用正确的连接字符串
- OpenDBX下连接使用MySQL