Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql only do not select duplicated values

Tags:

mysql

I am looking for a way to run a simple SELECT statment. I have a table which has two columns: id and email.

I want to run a SELECT statment that won't return duplicate values. For example, take the following data:

1   [email protected]
2   [email protected]
3   [email protected]
4   [email protected]

I want it to return only the following:

1   [email protected]
2   [email protected]

...and skip the duplicate values.

like image 726
DCHP Avatar asked Dec 06 '11 17:12

DCHP


2 Answers

SELECT MIN(id), email FROM some_table GROUP BY email
like image 154
Jonathan Rich Avatar answered Sep 28 '22 11:09

Jonathan Rich


SELECT DISTINCT email FROM table
like image 29
Henno Avatar answered Sep 28 '22 11:09

Henno