您的位置:首页 > 数据库

sql语句,对比数据时候用到

2013-05-27 17:22 288 查看
查询出有某两列相同的行:

select * from test a

where exists (

select 1

from test b

where b.学生姓名 = a.学生姓名

and b.手机号码 = a.手机号码

and (a.学校<> b.学校 or a.班级<> b.班级))

更改,合并某两项的数据:

update test1 set 手机1=(select distinct test2.手机1 from test2 where test2.学生姓名=test1.学生姓名 and test2.学号=test1.学号),

手机2=(select distinct test2.手机2 from test2 where test2.学生姓名=test1.学生姓名 and test2.学号=test1.学号)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐