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 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 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 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 Link to comment https://forums.phpfreaks.com/topic/173164-distinct-help/#findComment-913040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.