php - 不更新mysql中的多行

标签 php mysql

$match_id = 123; // this is the value to be updated
$update_item_number = "(3,4,5)"; // this is the id no where the value to be updated
//update query
$orders = "UPDATE orders SET item_number='$match_id' WHERE order_id IN'".$update_item_number ."'";
mysql_query($orders);

此查询未更新,我被困在这里请帮助我...

最佳答案

修改您的查询:

"UPDATE orders SET item_number=$match_id WHERE order_id IN $update_item_number";

整数不需要撇号(它们是可选的,但最好使用纯 int 值)。

此外,在 IN 语句中,语句 (...) 前后不应有 '

关于php - 不更新mysql中的多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14258522/

相关文章:

php - number_format() 导致错误 "A non well formed numeric value encountered"

php - 根据用户名或 ID 从数据库中检索特定行

php - 如果表 A 中包含的值被删除,如何将表 B 值(包含表 A 中的值)更改为 0

php - 使用php从mysql数据库检索所有数据的单个文件?

php - 从 MySQL 条目中提取某些信息

php - 存储用于显示内容的标签值

php - 在服务器上运行的 MySQL 查询在本地不起作用

mysql - 在使用 Laravel 4 的 Eloquent ORM 时如何使用我自己的列名?

mysql:用子查询更新,

mysql - AWS : Best way to automatically create MySQL dump of an RDS instance and store it to S3