select email, status_id, count(*) from customers group by email, status_id having count(*) > 1;
我想更新我的所有那些获得上述查询的记录。我想更新status_id,结果来自上面的查询。
我该怎么做?
请帮帮我。
答案 0 :(得分:0)
请测试此代码:
UPDATE customers
SET customers.status_id =
CASE
When COUNT(*) >1 Then 'value 1'
When COUNT(*) <1 Then 'value 2'
When COUNT(*) = 1 Then 'value 3'
ELSE 'SARB'
END
GROUP BY email, status_id
HAVING COUNT(*) >= 1
希望有所帮助