Page 1 of 1

Help with an SQL query [Simple..]

Posted: Tue Jun 29, 2010 12:26 pm
by bla5e

Code: Select all

SELECT id,name,email FROM intranet.users

Code: Select all

SELECT userid,groupid FROM intranet.users_associatedgroups WHERE groupid={$_POST['groupid']}
I have the name and e-mail of the users stored in the first query, and the group they are apart of in the 2nd query. My code is passing the groupid, and i want to know which users are in that group. Having a brain fart and just cant figure out how to do it.

userid is a reference from intranet.users ID

Help please?

Re: Help with an SQL query [Simple..]

Posted: Tue Jun 29, 2010 12:30 pm
by Ratzzak
Try this...

Code: Select all

SELECT id,name,email FROM intranet.users
WHERE id in (SELECT userid FROM intranet.users_associatedgroups WHERE groupid={$_POST['groupid']})

Re: Help with an SQL query [Simple..]

Posted: Tue Jun 29, 2010 12:31 pm
by bla5e
Ratzzak wrote:Try this...

Code: Select all

SELECT id,name,email FROM intranet.users
WHERE id in (SELECT userid FROM intranet.users_associatedgroups WHERE groupid={$_POST['groupid']})
lol thank you, having a really bad day today. planning an engagement for the weekend, work is packed, and the kid is sick. thank you again