开发者

UPDATE two rows - MySQL

开发者 https://www.devze.com 2023-02-06 07:59 出处:网络
I\'m trying to update two rows in my database using a query (which is going to be run from a PHP script) and there is just one Condition (WHERE). What I\'ve tried is:

I'm trying to update two rows in my database using a query (which is going to be run from a PHP script) and there is just one Condition (WHERE). What I've tried is:

$sql = 'UPDATE ' . CANNED_MESSAG开发者_运维知识库ES . "
                SET canned_message_content = '" . $db->sql_escape($content) . "', 
                    canned_message_title = '" . $db->sql_escape($title) . "'
                WHERE id = '" . intval($id) . "'" ;
$db->sql_query($sql);

Can you tell me whats wrong with my query? :)


This may be due to Quotes mismatch. Please use this

$sql = "UPDATE '" . CANNED_MESSAGES ."'
                SET canned_message_content = '" . $db->sql_escape($content) . "', 
                    canned_message_title = '" . $db->sql_escape($title) . "'
                WHERE id = '" . intval($id) . "' " ;


I highly doubt that two rows can have the same id column. Do they? If not, how could you update 2 rows by specifying a condition on a column with such a constraint?

0

精彩评论

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