What is wrong with this simple syntax?


  • 2
    C
    SELECT MIN(id), Email
    FROM Person
    GROUP BY Email;

  • 0

    What do you mean? The syntax is fine.

    You're not deleting anything, though.


  • 0
    C

    Thank you for your time answering!

    I was using SQL in SAS and the codes above worked fine to solve the problem of eliminating duple email address in SAS environment. However, when I tried it here in MySQL, it just does not work, not returning the desired outcome, unique email with lowest Id retained.


  • 1
    Y

    I think we need to actually delete the rows with duplicated emails from the table, not only select them out.


  • 0

    I don't know SAS but I'm pretty certain SELECT doesn't delete anything there, either. That's just not what SELECT is for.


  • 1
    C

    By SELECT you are showing things you want to show which means hiding the other things you don't want to present. But hiding things does NOT mean deleting. We can show the hidden things whenever we use SELECT to them, but we will no long be able to show things after deleting. So not SELECT-ing doesn't mean deleting. Here we need to use DELET.


  • 1
    H

    I'm writing the exactly same as yours. I thought use select at first. However it seems we need to delete the records from the table


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.