View Single Post

  #1 (permalink)  
Old 03-15-2007
rics
 
Posts: n/a
Default Question about select statement

Hello,

I have 3 tables.

* users
-- userid
-- username

* groups
-- groupid
-- groupname

* users_groups
-- usergroupid
-- userid
-- groupid

I wish to do a select that returns all the content of the
*users_groups* but with usernames and groupnames in place of userid
and groupid.

My actual select only return 1 record per user. This is the code:

select u.userid, u.username, g.groupname
from users u, groups g, users_groups ug
where u.userid = ug.userid and g.groupid = ug.groupid

How can I get all the records in *users_groups* ?

Any thougths?

Reply With Quote