I use this to update (add points) rows which mgroup
is 15
UPDATE ibf_members SET points = points + 500 WHERE mgroup = 15
What can I use to update (add points + 500) for rows which has its id
as 5
, 7
, 10
, 11
, 16
, 25
and also has mgroup
as 15
?
You can use the IN
clause for this, which is easier to read (and possibly more efficient?) than building a giant OR
list. Try something like:
UPDATE ibf_members
SET points = points + 500
WHERE mgroup = 15
AND id IN (5, 7, 10, 11, 16, 25);
只需在WHERE子句中添加另一个条件:
UPDATE ibf_members SET points = points + 500 WHERE mgroup = 15 AND id IN (5, 7, 10, 11, 16, 25)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.