首页 > 解决方案 > 根据另一张表上的数据更新一张表

问题描述

请任何人都可以用 php 代码帮助我解决这个问题我是 php 新手。我有 2 个名为“registration”表和“first_allotement”表的表

“注册”表:

Altno | pid | appno | name | college1 | college2 | college3 | college4  | college5 | college6 | college7 | college8 | college9 | college10

'first_allotement' 表:

Altno | appno | name | college | curdate | markdate | total | pdf

将“first_allotement”表中的“college”字段与“registration”表字段“college1”、“college2”.....“college10”进行比较,如果值与任何字段匹配,则将“registration”表中的相应字段更新为空值..所以请给我一个更好的php代码来解决它

标签: phpmysql

解决方案


使用更新加入:

update table registration join first_allotement
on registration .appno =first_allotement.appno and first_allotement.college=(registration.college1 or registration.college1 or registration.college2 or registration.college3 or registration.college4 or registration.college5 or registration.college6 or registration.college7 or registration.college8 or registration.college9 or registration.college10)
set registration.college1=null, registration.college2=null, registration.college3=null ....

推荐阅读