SELECT u.user_id FROM user_profile u LEFT JOIN team_member t ON u.user_id = t.user_id WHERE t.team_id <> 2
-----Original Message----- From: heiko mundle [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 8:08 AM To: [EMAIL PROTECTED] 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