Reply
Old 07-24-2006, 06:46 AM SQL Joins
numbenator's Avatar
Ultra Talker

Posts: 413
Location: London
HI,

IM attempting to join 3 tables but having problems

my tables are shown below

_intranetUsers

userID
foreName
surName

_intranetGroups

groupID
groupName

_intranetUsersGroupsLookup (primary table)

groupID
userID

I wish to select _intranetUsersGroupsLookup but look up , forename/surname from _intranetUsers and groupName from _intranetGroups.

However, i wish ALSO to show non matches in _intranetUsers and non matches in intranetGroups

My SQL is below :

SELECT a.groupID, a.userID, b.firstName, b.lastName, c.groupName FROM
_intranetUsersGroupsLookup a
RIGHT JOIN _intranetUsers b ON a.userID = b.userID
LEFT JOIN _intranetGroups c ON a.groupID = c.groupID
ORDER BY a.groupID

Problem is although the non matches for _intranetUsers is shown, When i define a RIGHT JOIN a to c instead of LEFT JOIN a to c i return NO records.
(there are users and groups NOT defined in _intranetUsersGroupsLookup that i wish to output)

Can anyone please help as this is well frustrating me.

cheers

Steve
__________________
www.mastech-solutions.com

Last edited by numbenator : 07-24-2006 at 06:49 AM.
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
When You Register, These Ads Go Away!
Reply     « Reply to SQL Joins
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10456 seconds with 12 queries