View previous topic :: View next topic |
Author |
Message |
telanor
Joined: 02 Sep 2005 Posts: 1
|
Posted: Fri Sep 02, 2005 1:48 Post subject: Need Help With Specific Mysql Query |
|
|
I need help figuring out exactly how I would write a mysql query that would do the following:
SELECT DISTINCT somefield FROM somedatabase WHERE something=something
and also select another field, the Id in this case, that goes along with the selected row. If I put "SELECT DISTINCT somefield, Id" I end up getting duplicate somefield entries |
|
Back to top |
|
|
monezz
Joined: 03 Jan 2005 Posts: 52 Location: The Netherlands
|
Posted: Wed Sep 07, 2005 14:43 Post subject: |
|
|
You need to specify which id you want from the distinct somefield.
you could use for example:
select max(id), somefield
from sometable
where someotherfield = somevalue
group by somefield |
|
Back to top |
|
|
|