The 'DISTINCT' mysql cmmand is used to eliminate duplicate values in a column. The mysql query as follows as:
SELECT DISTINCT field_name FROM table_name
SELECT DISTINCT field_name FROM table_name
Distinct in Mysql:
Consider the following table. table1 is name of this table.
Now we are going to get unique values in column 'id' by 'DISTINCT' mysql command like this:
SELECT DISTINCT id FROM table1
Now you'll get output like this:
You can see the table 'table1' which have unique values.SELECT DISTINCT id FROM table1
Now you'll get output like this:
Distinct multiple column in Mysql:
You can use multiple column for 'DISTINCT' in a query. But you can't get answer as you want.
The mysql query as follows as:
SELECT DISTINCT id, count FROM table1
You'll get output like this:
You can see the table 'table1' which displays all values in column 'id' and 'count'.
Related Post:
Related Post:
No comments:
Post a Comment