0

我正在尝试通过加入同一个表来更新同一个表,重复行跳过。我想将重复值的计数存储在 number_of_duplicates 字段中。

UPDATE 4_crem_three_entries a,(
    SELECT count(*) c,cream_id FROM 4_crem_three_entries 
    GROUP BY `c_phone` HAVING count( * ) >1
   ) b
SET number_of_duplicates=b.c 
WHERE a.cream_id=b.cream_id
4

1 回答 1

0

尝试这个

UPDATE 4_crem_three_entries 
SET number_of_duplicates=(SELECT count( * ) FROM 4_crem_three_entries c where c.cream_id=4_crem_three_entries.cream_id GROUP BY c.c_phone HAVING count( * ) >1)
于 2013-09-09T14:23:26.010 回答