Hi, a query like this should do the job select user_profile.user_id from user_profile left join team_member on (team_member.user_id=user_profile.user.id and team_member.team_id=2) where team_member.user_id is NULL;
Dobromir Velev [EMAIL PROTECTED] www.websitepulse.com ----- Original Message ----- From: "heiko mundle" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, January 28, 2003 16:08 Subject: Help with SELECT, JOIN and WHERE query > Hi, > > I got a difficult problem with a SELECT query: > > In my application there are two tables, one for all users (user_profile) one > for a user-in-team relation. > > I want to know, which user is still not in a speciffic team. Users can be in > more than one team, but we don't care about that. > > Example: > user_profile: > +---------+ > | user_id | > +---------+ > | 1000 | > | 1001 | > | 1002 | > | 1003 | > | 1004 | > | 1005 | > | 1006 | > | ... | > +---------+ > > team_member: > +---------+---------+ > | team_id | user_id | > +---------+---------+ > | 1 | 1000 | > | 1 | 1004 | > | 1 | 1005 | > | 2 | 1006 | > | 2 | 1003 | > | 2 | 1000 | > | 2 | 1001 | > | 2 | 1005 | > | 3 | 1001 | > | 3 | 1005 | > | 3 | 1002 | > | 3 | 1003 | > | ... | ... | > +---------+---------+ > > Who is not in team no. 2? > > Result: > +---------+ > | 1002 | > | 1004 | > +---------+ > > Thanks for any hint > > Kind regards Heiko Mundle > > -- > +++ GMX - Mail, Messaging & more http://www.gmx.net +++ > NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen! > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php