zero118 Posted November 21, 2006 Share Posted November 21, 2006 I know it's not PHP but it's somewhat related.I'm using the following:[CODE] $qry = "SELECT DISTINCT `name` FROM `$parts_database_table`"; $result2 = mysql_query($qry, $connection); $parts = mysql_fetch_row($result2);[/CODE] The problem is that I need to get the `id` field of those. I tried using [I]DISTINCT `name`, `id`[/I] but all it got me was a huge headache. Please someone help :-( Link to comment https://forums.phpfreaks.com/topic/28003-mysql-distinct/ Share on other sites More sharing options...
fenway Posted November 21, 2006 Share Posted November 21, 2006 You want a bunch of ids for distinct names? You can do this with a GROUP BY name, and just get the id field back, but be aware that you'll get an arbitrary id for records that share a name. Link to comment https://forums.phpfreaks.com/topic/28003-mysql-distinct/#findComment-128106 Share on other sites More sharing options...
zero118 Posted November 21, 2006 Author Share Posted November 21, 2006 Actually... you're very right. Sorry :) I hadn't thought logically through it. Link to comment https://forums.phpfreaks.com/topic/28003-mysql-distinct/#findComment-128110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.