MySQL - 更新字段相同的位置

时间:2013-10-22 08:54:05

标签: mysql

标题可能并没有多大用处,所以我会解释一下。基本上我有第一个查询:

UPDATE sales_records
INNER JOIN (SELECT buyer_full_name, buyer_address_1
FROM sales_records
GROUP BY buyer_full_name, buyer_address_1
HAVING COUNT(*)>1) multiorder
ON sales_records.buyer_full_name = multiorder.buyer_full_name
AND sales_records.buyer_address_1 = multiorder.buyer_address_1
SET processed=1
WHERE sales_records.buyer_full_name<>''
AND sales_records.buyer_address_1<>''

因此,上面列出了已经处理了多个订单的每个人= 1。但是,在同一个表中,订单的某些部分没有buyer_address_1或buyer_full_name但具有相同的sales_record_number字段。我需要将具有相同sales_record_number的剩余部分更新为已处理= 1。

这是我尝试过的(以及其他类似的变体),但它不起作用:

UPDATE sales_records
WHERE sales_record_number=(SELECT sales_record_number
FROM ebay_sales_records
WHERE processed=1)
AND processed=1

有什么想法吗?

0 个答案:

没有答案