webtuto Posted July 4, 2008 Share Posted July 4, 2008 hey i have a query that look like this $sql = mysql_query("select * from table where user='$cat'"); and on the table on the database i have names that are similar but while using mysql_fetch_array i dont want the names to be similar on the page while posting results so how can i do that ? Quote Link to comment https://forums.phpfreaks.com/topic/113249-i-dont-want-resemblance-on-the-result-need-help/ Share on other sites More sharing options...
pocobueno1388 Posted July 4, 2008 Share Posted July 4, 2008 I'm not exactly sure what your wanting, but it sounds like you want to use DISTINCT select *, DISTINCT(name) from table where user='$cat' Quote Link to comment https://forums.phpfreaks.com/topic/113249-i-dont-want-resemblance-on-the-result-need-help/#findComment-581840 Share on other sites More sharing options...
webtuto Posted July 4, 2008 Author Share Posted July 4, 2008 yeah but when i try this select DISTINCT * from `song` where category='$cat' it gives an error bcz i want all not just a row i want to use * not a row name Quote Link to comment https://forums.phpfreaks.com/topic/113249-i-dont-want-resemblance-on-the-result-need-help/#findComment-581844 Share on other sites More sharing options...
pocobueno1388 Posted July 4, 2008 Share Posted July 4, 2008 I think if you want to do it that way, your going to have to use GROUP BY as well. SELECT DISTINCT * FROM `song` WHERE category='$cat' GROUP BY category If that doesn't work, you may have to just manually type all the fields SELECT DISTINCT field1, field2 FROM `song` WHERE category='$cat' Quote Link to comment https://forums.phpfreaks.com/topic/113249-i-dont-want-resemblance-on-the-result-need-help/#findComment-581890 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.