datoshway Posted November 15, 2010 Share Posted November 15, 2010 I have three fields in my table. I need one of those fields to be distinct. How should I combine a SELECT DISTINCT and the regular queries? Quote Link to comment https://forums.phpfreaks.com/topic/218787-distinct-query-help/ Share on other sites More sharing options...
datoshway Posted November 15, 2010 Author Share Posted November 15, 2010 I should clarify a little. Sorry guys. $sql = "Select distinct one,two,three from $DB_TBLName"; Thats pulling all the results. What I need is to exclude the results that are duplicate. So i'd like to search the field "one" and make sure it is distinct. If it is not distinct, i'd like to exclude the entire entry. Quote Link to comment https://forums.phpfreaks.com/topic/218787-distinct-query-help/#findComment-1134718 Share on other sites More sharing options...
The Little Guy Posted November 16, 2010 Share Posted November 16, 2010 $sql = "Select distinct(one), two, three from $DB_TBLName"; Quote Link to comment https://forums.phpfreaks.com/topic/218787-distinct-query-help/#findComment-1134825 Share on other sites More sharing options...
datoshway Posted November 16, 2010 Author Share Posted November 16, 2010 Thanks! I ended up using this query and it seems to work well. $sql = "Select one,two,three from $DB_TBLName GROUP BY one"; Quote Link to comment https://forums.phpfreaks.com/topic/218787-distinct-query-help/#findComment-1135119 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.