php - 根据另一张表上的数据更新一张表
问题描述
请任何人都可以用 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代码来解决它
解决方案
使用更新加入:
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 ....
推荐阅读
- mysql - IS JSON_SEARCH 区分大小写
- reactjs - 异步 componentDidMount 未在 React Native 中执行
- python - if/elif 结构的意外输出
- xpages - xpages 按钮 - 可以在事件运行时更改文本或项目?
- sql - 令人困惑的 SET IDENTITY_INSERT 错误
- sql - SQL 连接列值并存储在额外的列中
- python - Django - 问卷 - ModelFormSet - 无法分配
- javascript - 使用 javascript 将项目移回原位
- c - 从服务器关闭客户端套接字打印出我已经打印的多个字符串
- linux - 如何通过 Docker 启动 FreeIPA Web UI?