How to get unique data from database[DISTINCT]

Sometime we stuck on fetching unique data from database. We use DISTINCT to fetch unique data removing duplicate entries. You also need to mention column name in your mysql statement. Here is how to use DISTINCT in mysql query.

You can write this query with DISTINCT statement like that:

mysql_query("SELECT DISTINCT(`column_name`) FROM `table_name`");

It’s working for me. Try this. Now use will get the unique data from your table with the mentioned column name.