简体   繁体   中英

Update multiple records in mysql

I have records in mysql database. What I need to know if how to update all ACR001 and SUP-001 at once?

id | cat_code | item_code  
-------------------------
1  | ACR001   | SUP-001
2  | ACR001   | SUP-001
3  | ACR001   | SUP-001
4  | ACR001   | SUP-001
5  | BCR001   | COM-001

您可以使用简单的更新查询

UPDATE table SET cat_code = 'NEWVALUE', item_code = 'NEWVALUE' WHERE cat_code = 'ACR001' AND item_code = 'SUP-001'

Depending on the field you need to update:

UPDATE table SET `Field_name`= 'new_value' WHERE cat_code = 'ACR001' AND item_code = 'SUP-001'

This query will update all records with the value of Field_name' depending on the value of new_value` where cat_code = 'ACR001' and if item_code = 'SUP-001'

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