From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
---|---|
To: | L van der Walt <mailing(at)lani(dot)co(dot)za> |
Cc: | pgsql-sql(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org |
Subject: | Re: A Not Join |
Date: | 2005-11-01 15:15:04 |
Message-ID: | 20051101151504.GL20349@pervasive.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
On Tue, Nov 01, 2005 at 04:27:01PM +0200, L van der Walt wrote:
> I have three table:
> Users - Contains username, ID etc...
> Permissions - A permission name and ID
> Link up table - The user.id and permission.id
>
> If a user.id and a permission.id row exists in the linkuptable the user
> have that permission granted.
>
> With the statement below I can see the permissions a user have.
>
> SELECT users.username, permissions.name
> FROM users INNER JOIN linkuptable
> ON (users.id = linkuptable.userid)
> INNER JOIN permissions
> ON (permissions.id = linkuptable.permissionid)
> WHERE users.username = 'DummyUser'
>
> How do I see the permissions that user DON'T have with a fast SQL statement.
>
> Thus, a NOT the statement for the above SQL statement
LEFT JOIN permissions ON (...)
WHERE permissions.id IS NULL
You might have to do the NULL check in a HAVING clause instead... try
it.
BTW, this is probably better asked on pgsql-sql.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2005-11-01 16:51:18 | Re: Oracle 10g Express - any danger for Postgres? |
Previous Message | Jim C. Nasby | 2005-11-01 15:09:18 | Re: SQL injection |
From | Date | Subject | |
---|---|---|---|
Next Message | David Durham | 2005-11-01 18:18:19 | Index lookup on > and < criteria |
Previous Message | Daryl Richter | 2005-11-01 14:45:09 | Re: Fwd: Re: Referencing |