$result = mysql_query ("SELECT *, DISTINCT category FROM products WHERE pause = 'off' ORDER BY category ASC");
This doesn't work. And most SQL wizards here will probably see why.
I need to select everything from the row, where the DISTINCT query products a result.
ie, if there are 5 results (out of 50 rows for ex.), it has has all fields from it.
How do you SELECT *, when you want to select DISTINCT?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
How do you SELECT *, when you want to select DISTINCT?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do you SELECT *, when you want to select DISTINCT?
DISTINCT selects distinct values in a group, not distinct rows. You need to use GROUP BY with some additional filtering