Question

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

Was it helpful?

Solution

you need to use the distinct keyword.

SELECT DISTINCT tags FROM myTABLE;

OTHER TIPS

You can use DISTINCT:

SELECT DISTINCT(tags) FROM myTABLE;

The SQL DISTINCT command used along with the SELECT keyword retrieves only unique data entries depending on the column list you have specified after it.

More Info:

use the keyword distinct

SELECT DISTINCT tags FROM myTABLE;

SELECT DISTINCT(tags) FROM myTABLE;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top