pouncer Posted April 13, 2007 Share Posted April 13, 2007 $sql_ = mysql_query("SELECT * FROM category_table WHERE `group` <> ''"); while ($row = mysql_fetch_array($sql_)) { $group = $row['group']; echo $group; } how can i make it stop showing duplicates because some categories belong to the same group. Link to comment https://forums.phpfreaks.com/topic/46931-query-help-how-to-avoid-duplicates/ Share on other sites More sharing options...
per1os Posted April 13, 2007 Share Posted April 13, 2007 "SELECT group FROM category_table WHERE `group` <> '' GROUP BY group" or "SELECT distinct(group) FROM category_table WHERE `group` <> '' GROUP BY group" That should do the trick. Link to comment https://forums.phpfreaks.com/topic/46931-query-help-how-to-avoid-duplicates/#findComment-228863 Share on other sites More sharing options...
neoform Posted April 13, 2007 Share Posted April 13, 2007 you need to have a key field to do this, but you can use something like this: (if the table has a key field called "id") SELECT DISTINCT id FROM category_table WHERE `group` <> '' Link to comment https://forums.phpfreaks.com/topic/46931-query-help-how-to-avoid-duplicates/#findComment-228864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.