spirito_libero
spirito_libero

Reputation: 1332

How to select only id by the unique value of other table

I have a table customers. How can I select only ids for the distinct values in the email column?

+----+------------------+
| Id | Email            |
+----+------------------+
| 1  | [email protected] |
| 2  | [email protected]    |
| 3  | [email protected]   |
| 4  | [email protected] |
| 5  | [email protected] |
+----+------------------+

So the result will be:

[1,2,3,5]

So far, I've tried:

select distinct id, email from customers group by id;

Upvotes: 1

Views: 40

Answers (1)

elyalvarado
elyalvarado

Reputation: 1296

select min(id) from Customers group by email;

Upvotes: 3

Related Questions