有A,B两个表,想用PHP将这两个表进行对比,查找两个表中每行数据是否相同,并将两个表中每行相同的数据在B表中 "Same"中写入数据"1",下面是两个表结构(两个表没有关联):
A表:
"User","Password","TLE","Address","Joined","Email"
B表:
"User","Password","TLE","Address","Joined","Email","Same"
现在想对比A,B两个表查找完全相同的每一行数据("User","Password","TLE","Address","Joined","Email"),如果都相同则在B表中的"Same"中写入1,否则"Same"写入"0"或让其为空,这个PHP怎样写,MYSQL语句怎样写,怎样去实现这功能?
你可以再改进一下
`update base
set base.Same = 1
from B base, A filter
where filter.User = base.User
and filter.Password = base.Password
and filter.TLE = base.TLE
and filter.Address = base.Address
and filter.Joined = base.Joined
and filter.Email = base.Email`
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。