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 :-( Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.