mysql
Get distinct records MySQL
SELECT DISTINCT
column_name1, column_name2
FROM
table_name;
DISTINCT clause in MYSQL is used to get record which are not duplicate to others. You can find distinct records from a table in MySQL using DISTINCT clause.
Example
If there is a table named students which has two columns named first_name and last_name and there are some records which has duplicate entry in first_name column.
If you want to get all the records where first_name column records are not same then run below query
SELECT DISTINCT first_name FROM students;
To get distinct records by first_name and last_name combination run below.
SELECT DISTINCT first_name, last_name FROM students;
Was this helpful?
Similar Posts