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

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

问题描述:

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

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?

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

我有这样的消息表,其示例值如下: p>

  msg_id recipient_id read locked new 
 0 1 NYY 
 2 1 YNN 
  code>  pre> 
 
 

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

我想知道为什么 p>

 更新`messages` SET`new` ='Y  ',`read` ='N',`locked` ='N',其中`recipient_id` = 1; 
  code>  pre> 
 
 

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

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

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