简体   繁体   中英

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; check the manual that corresponds to your MySQL server version for the right syntax to use near 'company=='xyz'' at line 1

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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