我正在尝试执行更新 ddbb 中多行的查询。我不确定是否会使用 UPDATE 或 ALTER 表。
我有这样一个数据库:
id | enrol | status | courseid | sortorder | name | password
622 self 0 152 1 somepass
623 auto 0 153 1 NULL
624 self 0 154 1 somepass
625 self 0 155 1 somepass
626 self 0 156 1 NULL
627 auto 0 157 1 somepass
628 self 0 158 1 somepass
629 self 0 160 1 somepass
630 self 0 161 1 somepass
631 self 0 162 1 NULL
632 self 0 163 1 NULL
我想更新密码为空的所有行,我有这个查询
UPDATE mdl_enrol SET password NULL WHERE password IS NOT NULL and enrol = "self" ;
出于某种原因 phpMyAdmin 返回:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL WHERE password IS NOT NULL and enrol = "self"' at line 1
提前致谢!
最佳答案
设置密码值时只需添加赋值运算符(“=”):
UPDATE mdl_enrol
SET password = NULL
WHERE password IS NOT NULL and enrol = "self" ;
关于mysql - 查询更新列数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32714177/