Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 4th, 2005, 08:51 AM
Registered User
 
Join Date: Oct 2004
Location: Mumbai, Maharashtra, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tovipul21
Default More than 1 Left Join in MS Access

If you have base table containing data plus key fields for a series of
related link tables, and you want to return a record set which contains all the records from the base table, and depending on if the key fields match, data from the link tables you can use the LEFT OUTER JOIN command which works fine for a single link table ie

Base Table AAAA
Link Table BBBB

SELECT * FROM AAAA LEFT OUTER JOIN BBBB ON AAAA.key=BBBB.key

But as soon as I increase this to say two (3) links tables it fails when using MS Access database from inside ADO Control.

Base Table AAAA
Link Table BBBB
Link Table CCCC
Link Table DDDD

SELECT *
FROM AAAA LEFT OUTER JOIN BBBB ON AAAA.key=BBBB.key
LEFT OUTER JOIN CCCC ON AAAA.key = CCCC.key
LEFT OUTER JOIN DDDD ON AAAA.key = DDDD.key

Can anyone advise how the above can be solved for tables in an MS Access (Office 2000) database.


Regards

Vipul Mehta


Vipul Mehta
Software Developer
Chenoa Information & Software Services Pvt Ltd
Reply With Quote
  #2 (permalink)  
Old January 4th, 2005, 02:51 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   When you say "base" table, do you mean a junction table or a main table? And when you say "Link" table, do you mean a look up table? I think this would help based on the direction of the relationships.

   Are the "linked" tables looked up through a junction table like this:

tblEmployees <--- tblAssetAssignments ---> tblAssets

Or more are they just look ups like this:

tblEmployees ---> tblCities
tblEmployees ---> tblStates

Thanks,


mmcdonal
Reply With Quote
  #3 (permalink)  
Old January 5th, 2005, 01:47 AM
Registered User
 
Join Date: Oct 2004
Location: Mumbai, Maharashtra, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tovipul21
Default

 Hi,
    I have 1 main table whose Primary Key becomes FK in 3 other tables. So I have written the following query that doesnt work. It give me error 'Syntax Error (missing operator) in query expression'. Plz help me out.

SELECT c.[Name], cp.[PolicyNumber], cp.[NameOfPolicy]
FROM
(Contact c LEFT OUTER JOIN [Contact_Policy] cp ON c.[ContactPK] = cp.[ContactFK])
LEFT OUTER JOIN [Contact_Family] cf ON c.[ContactPK] = cf.[ContackFK]
LEFT OUTER JOIN [Contact_Loan] cl ON c.[ContactPK] = cl.[ContactFK]


Regards,
 Vipul Mehta

Vipul Mehta
Software Developer
Chenoa Information &amp; Software Services Pvt Ltd
Reply With Quote
  #4 (permalink)  
Old January 7th, 2005, 06:25 PM
Authorized User
 
Join Date: Jul 2004
Location: lagos, ikeja, Nigeria.
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via ICQ to chipset Send a message via MSN to chipset Send a message via Yahoo to chipset
Default

hi,
 i also had a close problem like your some weeks back. although i didn't get a solution to the three table JOINing. well i came to a concultion. i did some research on my own, i found out that Access support fractional part of SQL. I think the three table JOINing stuff will not work in ACCESS. but i didnt give. i use another method. try look deeply into the DISTINT, WHERE CLAUSE. you might fing you anwser there. i had to re-structured my table. you can use an ID to JOIN two table, and then use the WHERE CLAUSE to bring in the 3rd table using the 3rd table ID.

please you can send me a mail if you find the syntax for the 3-table JOIN.:)
SEE-YA

Reply With Quote
  #5 (permalink)  
Old January 7th, 2005, 07:57 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Use the graphical query editor.
place the three tables and connect the id's
Now select the connection line with a right-click and use option 2 or 3 to get the LEFT , RIGHT join arrow pointing in the direction you need.

Switch to the SQL mode to show the sql code


Jaime E. Maccou
Reply With Quote
  #6 (permalink)  
Old November 21st, 2008, 05:58 PM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well after following the last point of advice, switching to the graphical editor, i did complete the task, but for more exacting detail, after it was complete and appeared to be functioning i reversed it back to sql view. Access can do it, but expects the joins to nest within each other.
so. . .
from tbl1 inner join (tbl2 inner join tbl3 on tbl3.fld1=tbl2.fld1) on tbl1.fld2 = tbl3.fld2

notice tbl3 (the meeting table with links to the other 2) is at the deepest level, linking up to item 2 at that level then up to table 1 on the top.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
join table using ms access ct VB.NET 1 October 23rd, 2006 03:16 PM
left outer join 2 or 3 tables in ms access keyvanjan Classic ASP Basics 2 February 2nd, 2006 06:42 PM
left outer join 2 or 3 tables in ms access keyvanjan SQL Server ASP 0 January 30th, 2006 03:33 AM
left join msrnivas Classic ASP Databases 2 October 15th, 2004 07:37 AM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM



All times are GMT -4. The time now is 08:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.