MYSQL中的UPDATE子句可以使用PHP在一个查询中更新多个记录吗?

时间:2022-08-16 00:12:09

well i have this messages table with sample values like these:

好吧,我有这样的消息表,样本值如下:

msg_id  recipient_id   read   locked   new
  0         1            N       Y      Y
  2         1            Y       N      N

ok, so lets just say this is a messaging table, and i want to reset all messages addressed to recipient with id=1

好的,所以我们只想说这是一个消息传递表,我想重置发往id = 1的收件人的所有邮件

i was wondering why

我想知道为什么

UPDATE `messages` SET `new`='Y',`read`='N',`locked`='N' where `recipient_id`=1;

doesn't work, MYSQL always returns 0 affected rows... can anyone help me?

不起作用,MYSQL总是返回0个受影响的行...任何人都可以帮助我吗?

to robert gamble: yes, im sure the values were changed, since my purpose for this update query is to reset the data i was using for the testing phases :D

罗伯特赌博:是的,我确定值已经改变,因为我更新查询的目的是重置我用于测试阶段的数据:D

1 个解决方案

#1


4  

You have some floating single-quotes in there. You may be assigning one string to another or something.

你有一些浮动的单引号。您可能正在将一个字符串分配给另一个或其他东西。

It's ok to just say

可以这么说

UPDATE messages  
SET new = 'y', read = 'N', locked = 'N'  
WHERE recipient_id = 1

#1


4  

You have some floating single-quotes in there. You may be assigning one string to another or something.

你有一些浮动的单引号。您可能正在将一个字符串分配给另一个或其他东西。

It's ok to just say

可以这么说

UPDATE messages  
SET new = 'y', read = 'N', locked = 'N'  
WHERE recipient_id = 1