logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Need Help With Specific Mysql Query

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
telanor



Joined: 02 Sep 2005
Posts: 1

PostPosted: Fri Sep 02, 2005 1:48    Post subject: Need Help With Specific Mysql Query Reply with quote

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
View user's profile Send private message
monezz



Joined: 03 Jan 2005
Posts: 52
Location: The Netherlands

PostPosted: Wed Sep 07, 2005 14:43    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group