> 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.
What you want is a left join with a =null condition.. BTW recommend unique
column names, it makes this shorter since you wouldn't need the table
names..

SELECT user_profile.user_id FROM user_profile
  LEFT JOIN team_member ON user_profile.user_id = team_member.user_id
  WHERE team_member.user_id = null

> Example:
> user_profile:
> +---------+
> | user_id |
> +---------+
> |    1000 |
> |    ...  |
> +---------+
>
> team_member:
> +---------+---------+
> | team_id | user_id |
> +---------+---------+
> |       1 |    1000 |
>
> Who is not in team no. 2?
>
> Result:
> +---------+
> |    1002 |
> |    1004 |
> +---------+
>
> Thanks for any hint
>
> Kind regards Heiko Mundle
>

William R. Mussatto, Senior Systems Engineer
Ph. 909-920-9154 ext. 27
FAX. 909-608-7061



---------------------------------------------------------------------
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

Reply via email to