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 example@hotmail.com
2 example12@hotmail.com
3 example@hotmail.com
4 example@hotmail.com
I want it to return only the following:
1 example@hotmail.com
2 example12@hotmail.com
...and skip the duplicate values.
SELECT MIN(id), email FROM some_table GROUP BY email
SELECT DISTINCT email FROM table
If you don't need ID
use
SELECT DISTINCT email FROM `TABLE_NAME`
else If you need the First ID
use
SELECT MIN(ID),email FROM `TABLE_NAME` GROUP BY email
There are several ways to accomplish this, one is to use the DISTINCT clause:
SELECT DISTINCT email FROM your_table;
another way is to summarize counts of the values:
SELECT COUNT (*), email from your_table GROUP BY email;
SELECT DISTINCT UNIQUE_FEILD_NAME FROM YOUR_TABLE_NAME
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.