简体   繁体   中英

php/mysql: update value in multiple rows

I have a table of horses in a classifieds site. The fields in question are:

uniquevalue (random alphanumeric given to each horse ad in any given order - same one is applied to between 1 and 6 horse ads; max 6 ads in an order. This doubles up as the $item_number in the paypal ipn transaction)

ppconfirmed (a 1,0 boolean, default=0, to be switched to 1 when paypal ipn runs on successful transaction)

The paypal ipn script updates a different table in the db with all the appropriate info. That's running fine.

What I need to happen: each horse record should have the ppconfirmed value set to 1, for each horse whose uniquevalue field matches the $item_number used in the paypal ipn post.

Hope that makes sense!

Austen

您需要的是带有JOIN子句的UPDATE语句,与第一篇http://dev.mysql.com/doc/refman/5.0/en/update.html中描述的语句非常相似

比这更难

UPDATE yourTable SET ppconfirmed = 1 WHERE uniquevalue = '$item_number'

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