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. Quote Link to comment 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. Quote Link to comment 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` <> '' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.