开发者

php mysql multiple update do nothing

$query = "UPDATE TABLE1 
  SET (row1 = '$val1' WHERE row5 = '$someid' AND active = 'yes')
    , (row1 = '$val2' WHERE row5 = '$someid' AND active = 'yes')
    , (row1 = '$val3' WHERE row5 = '$someid' AND active = 'yes')";

mysql_query($query);

This query does nothing. I c开发者_C百科an not update data.

What am I doing wrong?


UPDATE `table` SET `name`= case `id` 
    when 1 then "Alex"
    when 2 then "John"
    when 3 then "Steve"
 end 
WHERE `id` in(1,2,3)

Isn't it?


$sql_string='
UPDATE `TABLE1` SET `row1`= case `id` 
    when 1 then "'.$val1.'"
    when 2 then "'.$val2.'"
    when 3 then "'.$val3.'"
 end 
WHERE `row5 ` in('.$someid.','.$someid.','.$someid.') AND  `active`= "yes"';
mysql_query($sql_string);


Add the following code to you php file and you'll understand what's wrong

ini_set('display_errors', 1);
error_reporting(E_ALL);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜