简体   繁体   English

mysql中如何更新两行是否相同

[英]how to update if two row is same in mysql

this code is select item name and update value 此代码是选择商品名称和更新值

and i want if item name and company name is same then update 我想如果项目名称和公司名称相同,然后更新

like that 像那样

  $result = mysql_query("UPDATE stock SET  quantity=quantity - $quantity  WHERE itemname='$itemname',company='$company'")

but its not working it is showing this error 但它不起作用,它显示此错误

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'company=='xyz'' at line 1 检查与您的MySQL服务器版本相对应的手册,以在第1行的'company =='xyz'附近使用正确的语法

original code and this is working 原始代码,这是工作

  $result = mysql_query("UPDATE stock SET  quantity=quantity - $quantity  WHERE itemname='$itemname'")

how can i do this please help me 我该怎么做请帮助我

thanks 谢谢

使用AND运算符:

WHERE itemname='$itemname' AND company='$company'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM