196. 删除重复的电子邮箱【Problem:Every derived table must have its own alias】

SQL-Boy上线,最近在写SQL语句遇到了这样的问题。

Problem:Every derived table must have its own alias

错误语句如下

delete from Person where id not in (
    select id from 
    (
        select min(id)  as id
        from Person 
        group by email
    )
    
);

百度一波·

【mysql解决方案】ERROR 1248 (42000): Every derived table must have its own alias

问题在于在多级查询的过程中,会需要给表一个别名。

改成下面的语句就好使了

delete from Person where id not in (
    select id from 
    (
        select min(id)  as id
        from Person 
        group by email
    )new_table
    
);

基础不牢,地动山摇
QAQ

posted @ 2024-04-19 11:31  pengge666  阅读(8)  评论(0编辑  收藏  举报