通过比较列更新MYSQL表

通过比较列更新MYSQL表,mysql,Mysql,求你了,我需要帮助。 如果我有一个类似下图的MYSQL表,例如: Full Name Customer _ Type Referrer Wayne Brown Standard Neil White Neil White Standard Wayne Brown Gordon Smith Standard Neil White Rukky Dick Standard Neil White Dorothy

求你了,我需要帮助。 如果我有一个类似下图的MYSQL表,例如:

Full Name     Customer _ Type Referrer 
Wayne Brown   Standard        Neil White 
Neil White    Standard        Wayne Brown 
Gordon Smith  Standard        Neil White 
Rukky Dick    Standard        Neil White 
Dorothy Ann   Standard        Tracy Cool 
Tracy Cool    Standard        Neil White 
Anthony Josh  Standard        Neil White 
我如何编写更新声明,将Neil White这样的客户类型更改为“高级”,因为他推荐了5个或更多的人

我已经尝试过这个代码,但它没有给我结果

Update customers set customer_type = “Premium” where full_name = (select referrer from customers having count(referrer) >= 5)

谢谢。

尝试执行以下操作:

UPDATE `your_table` as t1 
    INNER JOIN (select count(*) as `total` 
            from `your_table` as t2 
            where t2.`full_name_customer`= t1.`full_name_customer`
            group by t2.`referrer`
     ) as t3
 SET`full_name_customer`='Premium' 
 WHERE t3.total >= 5

请在此处以纯文本形式发布代码,而不是以图像形式发布,这些图像可能难以阅读,无法复制粘贴以帮助测试代码或用于回答,并且对使用屏幕阅读器的人不友好。您可以编辑问题以在问题正文中添加代码。使用
{}
按钮格式化任何代码块,或使用四个空格缩进以获得相同效果。您可以使用
COUNT()
(可能带有have)或
num_rows()
UPDATE