Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 516
Location: London
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE

Last edited by numbenator; 07-24-2006 at 06:49 AM..
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Reply     « Reply to SQL Joins
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.08176 seconds with 12 queries