Mr Chris Posted September 4, 2009 Share Posted September 4, 2009 Hi, Have a very silly question. If I want to query a distinct name out of mysql database i'd use: Select DISTINCT name from names However, if I wanted the id of that distinct name also outputted BEFORE the name I thought i'd use Select DISTINCT id, name from names But that does no longer return distinct only records. Can anyone help? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/173164-distinct-help/ Share on other sites More sharing options...
kickstart Posted September 4, 2009 Share Posted September 4, 2009 Hi Distinct is returning you unique rows. Hence if it has multiple IDs for a name it will bring back the name multiple times. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/173164-distinct-help/#findComment-912799 Share on other sites More sharing options...
dreamwest Posted September 5, 2009 Share Posted September 5, 2009 You need to select distinct * when selecting multiple fields, the order by name Quote Link to comment https://forums.phpfreaks.com/topic/173164-distinct-help/#findComment-913010 Share on other sites More sharing options...
suresh64633 Posted September 5, 2009 Share Posted September 5, 2009 Hi, Try this Select id, name from names group by name Quote Link to comment https://forums.phpfreaks.com/topic/173164-distinct-help/#findComment-913040 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.