如何使用PHP代码比较mysql中的两个表? [英] How to compare the two tables in mysql using the PHP code?

查看:80
本文介绍了如何使用PHP代码比较mysql中的两个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有两个表,我必须比较表数据,如果数据匹配,则为列状态赋值是,如果不匹配然后将值No分配给该状态列,我必须为多个值执行此操作。我需要使用PHP执行此操作,并在PHP表中显示具有匹配值状态和不匹配值状态的数据。



提前感谢。



我尝试了什么:



我尝试过sql查询并能够获取不匹配的值在表中但不能将状态分配给匹配和不匹配的值。

Hi,

I have two tables and I have to compare the tables data and if data matches that assign the value "Yes" to the column status and if unmatched then assign the value "No" to that status column and i have to do this for multiple values. I need to do this using PHP and display the data in PHP table with the matched value status and unmatched value status.

Thanks in advance.

What I have tried:

I have tried sql query and able to fetch the unmatched values in table but not able to assign the status to matched and unmatched values.

推荐答案

我想你会找到 MySQL:INTERSECT运算符 [ ^ ]最有帮助。



针对另一个表运行每个表UPDATE以使用简单的IN设置是和否 不在。




I think you'll find MySQL: INTERSECT Operator[^] most helpful.

Run each table UPDATE against the other table to set 'Yes' and 'No' with simple "IN" and "NOT IN".



你能帮我解决一下正确的问题吗?我需要对php表中的每个值应用Yes或No。
Can you please help me out with the proper query? I need to apply 'Yes' or 'No' against each of the values in the php table.


这篇关于如何使用PHP代码比较mysql中的两个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆