查询出有某两列相同的行:
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.学号)
本文介绍如何使用SQL查询找出两个表中具有相同学生姓名和手机号码但其他字段不同的记录,并展示了如何通过更新语句来合并这些记录的相关信息。
1678

被折叠的 条评论
为什么被折叠?



