任何人都可以用php代码来帮助我解决这个问题,我是php的新手。我有2个名为“ registration”表和“ first_allotement”表的表
“注册”表:
Altno | pid | appno | name | college1 | college2 | college3 | college4 | college5 | college6 | college7 | college8 | college9 | college10
“第一批”表:
Altno | appno | name | college | curdate | markdate | total | pdf
比较“ first_allotement”表中的“ college”字段和“ registration”表字段“ college1”,“ college2” .....“ college10”(如果值与任何字段匹配),然后更新“ registration”表中的相应字段具有空值..所以请给我一个更好的PHP代码来解决它
答案 0 :(得分:0)
使用更新联接:
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 ....