On Sun, 11 Apr 2004, Lloyd thomas wrote:
>I have a table with user id's and another with user id's linked to a group.
>
>users table
>|user_id| username |
>| 1 | Lloyd Thomas|
>| 2 | John Smith |
>
>Group table
>|group id| user_id|
>| 1 | 1 |
>
>I am trying to create a query which selects a user where it is not part of a
>specified group. But it does not seem to work as I get multiple results for
>the same user id's.
>
>sql---------------------------------------------------
>Select U.user_id from
>users as U, grp_user as G where U.user_id != G.user_id
>------------------------------------------------------------
You'll get a user_id for each group that the user is not a member off. You
need an extra where clause selecting which group you're checking for:
Select U.user_id
from users as U, grp_user as G
where U.user_id != G.user_id AND G.group_id != <group>;
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
--
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST MS ATTACHMENTS
/ \
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]