本文介绍了在MySQL中更新多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过这样做来更新MySQL数据库中一个表中的多行.而且它不起作用.
I'm trying to update multiple rows in one table in MySQL database by doing this. And its not working.
$query = "UPDATE cart SET cart_qty='300' WHERE cart_id = '21';
UPDATE cart SET cart_qty='200' WHERE cart_id = '23';
UPDATE cart SET cart_qty='100' WHERE cart_id = '24';";
mysql_query($query,$link);// $link is specified above
任何人都知道这是怎么回事.
Anyone know what is wrong with this.
推荐答案
来自 PHP文档:
;
分隔SQL语句,因此如果要继续使用mysql_query
函数,则需要分隔查询...
The ;
separates SQL statements, so you need to separate the queries if you want to continue using the mysql_query
function...
这篇关于在MySQL中更新多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!