Re: Help with a query - Mailing list pgsql-general

From Erwin Van de Velde
Subject Re: Help with a query
Date
Msg-id 200402262308.58230.erwin.vandevelde@ua.ac.be
Whole thread Raw
In response to Help with a query  (Alexander Cohen <alex@toomuchspace.com>)
List pgsql-general
Hi,

Without further information, this is rather difficult, but assuming that you
have a table with userdata with a primary key UID and a unique UserName, and
that you have a table of usergroups with a primary key GID and unique
GroupName, the best way is to make a third table Users_Usergroups e.g.
where you put the couples (UIDX, GIDX) for a user with UID=UIDX and who is in
group GIDX.
The query would then be:
SELECT GroupName FROM Users_Usergroups JOIN Users ON Users.UID =
Users_Usergroups.UID JOIN Usergroups ON Usergroups.GID = Users_Usergroups.GID
WHERE UserName Like 'The User';

Greetings,
Erwin Van de Velde
Student of University of Antwerp
Belgium


On Thursday 26 February 2004 22:47, Alexander Cohen wrote:
> Hi,
>
> Im trying to get a list of all groups that a certain user is a member
> of. Can anyone help me with the sql to get that?
>
> thanks!


pgsql-general by date:

Previous
From: Alexander Cohen
Date:
Subject: Help with a query
Next
From: Alex Satrapa
Date:
Subject: Re: postgreSQL licenseing