[英]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) uniquevalue (按任意给定顺序分配给每个马广告的随机字母数字-相同的应用于1到6个马广告;一个订单中最多6个广告。这在paypal ipn交易中加倍为$ item_number)
ppconfirmed (a 1,0 boolean, default=0, to be switched to 1 when paypal ipn runs on successful transaction) ppconfirmed (一个1,0布尔值,默认= 0,当成功交易Paypal ipn时将其切换为1)
The paypal ipn script updates a different table in the db with all the appropriate info. paypal ipn脚本使用所有适当的信息更新数据库中的其他表。 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. 我需要发生的事情:每匹马记录的pp确认值都应设置为1,因为其唯一值字段与paypal ipn帖子中使用的$ item_number相匹配的每匹马。
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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.