I have table pro
like this :
id category details
1 f weqweq
2 m dqweq
3 f xcxzc
4 m eqweqw
5 f asweq
6 c xzsda
Now if i try something like :
SELECT DISTINCT category FROM pro
i get only m
and c
if i try :
SELECT category FROM pro GROUP BY category
i get only f
and c
How i can query to get all m,f,c
only once?!
Use GROUP BY:
SELECT * FROM pro GROUP BY `category`
select category from pro group by category
This is a issue in your PHP implementation.
Your query will get all your categories.
SELECT DISTINCT category FROM pro
Take a look here:
try this one,
SELECT a.*
FROM pro a
INNER JOIN
(
SELECT category, MIN(details) minDetail
FROM pro
GROUP BY category
) b ON a.category = b.category AND
a.details = b.minDetail
follow-up question: what will be the output from the details
column?