sql 查询相同字段表 少掉的数据
时间:2011-12-14
来源:互联网
table1
id name gender age createdate
1 张三 男 23 2011-12-01
2 张三 男 25 2011-12-09
3 李四 女 19 2011-11-03
4 王五 男 28 2011-11-11
table2
id name gender age createdate
1 张三 男 23 2011-12-01
2 李四 女 19 2011-11-03
3 王五 男 28 2011-11-11
1.查询两张表中缺少的数据
2.如果两张表只能据姓名做必配又如何做?
显示结果
id name gender age createdate
2 张三 男 25 2011-12-09
id name gender age createdate
1 张三 男 23 2011-12-01
2 张三 男 25 2011-12-09
3 李四 女 19 2011-11-03
4 王五 男 28 2011-11-11
table2
id name gender age createdate
1 张三 男 23 2011-12-01
2 李四 女 19 2011-11-03
3 王五 男 28 2011-11-11
1.查询两张表中缺少的数据
2.如果两张表只能据姓名做必配又如何做?
显示结果
id name gender age createdate
2 张三 男 25 2011-12-09
作者: CCXY_CPP 发布时间: 2011-12-14
SQL code
select * from table1 where not exists(select 1 from table2 where name=a.name and gender=a.gender and age=a.age and createdate=a.createdate)
作者: qianjin036a 发布时间: 2011-12-14
select name1字段 from table1 where Name字段 not in (select Name2字段 from Table2表)
1.你看你以哪个表做基准来对比。
2.这二张表不建议你用姓名来做为对比的字段,重名的人太多了。
比如:
1 张三 男 23 2011-12-01
2 张三 男 25 2011-12-09
1.你看你以哪个表做基准来对比。
2.这二张表不建议你用姓名来做为对比的字段,重名的人太多了。
比如:
1 张三 男 23 2011-12-01
2 张三 男 25 2011-12-09
作者: xfxyxy 发布时间: 2011-12-14
SQL code
晴天大大写掉了个a
select * from table1 a where not exists(select 1 from table2 where name=a.name and gender=a.gender and age=a.age and createdate=a.createdate)
晴天大大写掉了个a
作者: fredrickhu 发布时间: 2011-12-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28