If your column in mysql table contains duplicate values, then you need to display distinct values by mysql command 'DISTINCT' and 'GROUP BY'.
You can see the table 'table1' which have unique values.
You can also display unique values using 'GROUP BY' mysql command. If you want to select distinct values from one column and also other values from table, then you can use mysql command 'GROUP BY'. The mysql query is:
SELECT * FROM table_name GROUP BY column_name
Now we are going to get unique values in column 'id' by 'GROUP BY' mysql command like this:
SELECT * FROM table1 GROUP BY id
Now you'll get output like this:
You can see the column 'id' values in mysql table 'table1' are unique.
Related Post:
Select unique values in Mysql by distinct:
The mysql command 'DISTINCT' is used to select distinct values. The mysql query for select distinct values as follows as:
SELECT DISTINCT column_name FROM table_name
Consider the following table. table1 is name of this table.
Consider the following table. table1 is name of this table.
Select unique values in Mysql by 'Group by':
You can also display unique values using 'GROUP BY' mysql command. If you want to select distinct values from one column and also other values from table, then you can use mysql command 'GROUP BY'. The mysql query is:
SELECT * FROM table_name GROUP BY column_name
Now we are going to get unique values in column 'id' by 'GROUP BY' mysql command like this:
SELECT * FROM table1 GROUP BY id
Now you'll get output like this:
You can see the column 'id' values in mysql table 'table1' are unique.
Related Post:
Change column name in mysql
Change column size in mysql table
Delete column in mysql table
Add column after specific field in mysql table
Move columns in mysql table
Change column size in mysql table
Delete column in mysql table
Add column after specific field in mysql table
Move columns in mysql table