sql not exists 用法
2016-03-23 18:30
423 查看
选择存在于tA表中,但其中name不存在于tB表中的数据
select id, name, gender, classId from tA where not exists (select name from tB where tA.name=tB.name)
not in 的写法,同样的效果,但是在大数据量的时候效率不高
select id, name, gender, classId from tA where name not in (select name from tB where tA.name=tB.name)
或者
select id, name, gender, classId from tA where name not in (select name from tB)
select id, name, gender, classId from tA where not exists (select name from tB where tA.name=tB.name)
not in 的写法,同样的效果,但是在大数据量的时候效率不高
select id, name, gender, classId from tA where name not in (select name from tB where tA.name=tB.name)
或者
select id, name, gender, classId from tA where name not in (select name from tB)
相关文章推荐
- Mysql新建用户和数据库并授权
- MongoDB数据库命令总结
- Mysql 入门第二课
- 通过DBCA为数据库添加EM选件,成功登陆OEM
- 收藏的mysql语句
- MySQL触发器更新本表数据异常:Can't update table 'tbl' in stored function/trigger because it
- SQLite Expert查看float数据
- MySQL 中的 InnoDB 与 MyISAM
- MySQL数据库事务简介
- Mysql下SELECT的结果集作为UPDATE的WHERE条件时的SQL语法
- ORACLE ADF: VO ViewCriteria IN查询
- mysql图形化管理工具 workbench查询快捷键修改
- JDBC要点总结、SQL注入示例(Statement和PreparedStatement)
- 关于<resultMap> 设置时存在数据库中不存在的字段名
- redis应用场景
- ORACLE之搭建DG(ADG方式)
- php安装redis
- mysql导出csv文件excel打开后数字用科学计数法显示且低位变0的解决方法
- ORACLE ADF:VO SQL绑定
- mysql timestamp 值不合法问题