MySQL Forums
Forum List  »  Newbie

If I want unique values only for a particular column, can I use DISTINCT? If not, what should I use?
Posted by: Mike M
Date: March 22, 2021 01:52PM

Hello everyone,

I would like to have unique email addresses in the Email column.

The table:

+----+------------------+
| Id | Email |
+----+------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
| 3 | john@example.com |
+----+------------------+

The result should be:

+----+------------------+
| Id | Email |
+----+------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
+----+------------------+

My SQL attempt:
SELECT DISTINCT Id Email
FROM Person

It doesn't give me the result I want. What is wrong with this?

Thank you!

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.