Search code examples
phpsqlmysqlalgorithmdistinct-values

SQL Query for Distinctive Values (entries)


lets say i have this query

SELECT tags FROM myTABLE;

and the result of this comes like

CARS 
BIKES
BIKES 
3D 
PHOTOSHOP 
CARS 
3D 
ANIMALS 
NATURE 
PHOTOSHOP

what i want to do is not reapeat any word in Result... only fetch the distinctive entries once...

like

CARS 
BIKES 
3D 
PHOTOSHOP 
ANIMALS 
NATURE

could this be done with only SQL... if not then can anybody suggest an easy algo for this...

p.s i am using PHP & mySQL


Solution

  • you need to use the distinct keyword.

    SELECT DISTINCT tags FROM myTABLE;