Solved

Left join queries

Posted on 2008-06-19
6
205 Views
Last Modified: 2013-11-28
In access I have 4 tables each which has a common change #. I am trying to create a query that will do a left join on one of the tables to add info from the other three, if there is anything to add, some records will have additions and some will not. I get one left join to work but when trying to add other 2 it doesnt work. Is there a limit or is my code wrong? I have posted it below. Thanks

SELECT Time.[Change Number], Time.Summary, Time.[Area], Time.Code, Time.Category, Time.[Start Time], Time.[End Time], Time.[Total Duration], Time.[Service], Time.[Service Start Time], Time.[Service End Time], Time.[Reason], Time.[Group], Time.Service.[Impact Service], Time.Product.[Impact Service], Time.Al, Al.[Impact Application]
FROM Time LEFT JOIN Al ON Time.[Change Number] = Al.[Associated Change Order Number]
LEFT JOIN Service ON Time.[Change Number] ] = Al.[Associated Change Order Number]
LEFT JOIN Service ON Product.[Change Number] ] = Product.[Associated Change Order Number]
WHERE (((Time.[Change Area]) Like "*Amr*"));
0
Comment
Question by:pgmtkl
6 Comments
 

Expert Comment

by:suresh-infotech
ID: 21821604
Hi. try this

SELECT Time.[Change Number], Time.Summary, Time.[Area], Time.Code, Time.Category, Time.[Start Time], Time.[End Time], Time.[Total Duration], Time.[Service], Time.[Service Start Time], Time.[Service End Time], Time.[Reason], Time.[Group], Time.Service.[Impact Service], Time.Product.[Impact Service], Time.Al, Al.[Impact Application]
FROM ((Time LEFT JOIN Al ON Time.[Change Number] = Al.[Associated Change Order Number])
LEFT JOIN Service ON Time.[Change Number] ] = Al.[Associated Change Order Number])
LEFT JOIN Service ON Product.[Change Number] ] = Product.[Associated Change Order Number]
WHERE (((Time.[Change Area]) Like "*Amr*"));
0
 

Author Comment

by:pgmtkl
ID: 21821669
I get join expression not supported. Does that have to do with access?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21827133
pgmtkl,

Perhaps, there are certain join types that Access just has trouble resolving.
Your statement might just be too complex for Access (Jet-SQL).

Here are some good links on the subject:
http://support.microsoft.com/kb/208878
http://support.microsoft.com/kb/103429

Try to combine sets of joins into one query, then join the joined queries.
Make sense?
;-)

JeffCoachman
 
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 19

Accepted Solution

by:
frankytee earned 500 total points
ID: 21828942
you have too many ] brackets in your join, try:
SELECT Time.[Change Number], Time.Summary, Time.[Area], Time.Code, Time.Category, Time.[Start Time], Time.[End Time], Time.[Total Duration], Time.[Service], Time.[Service Start Time], Time.[Service End Time], Time.[Reason], Time.[Group], Time.Service.[Impact Service], Time.Product.[Impact Service], Time.Al, Al.[Impact Application]

FROM Time LEFT JOIN Al ON Time.[Change Number] = Al.[Associated Change Order Number]
LEFT JOIN Service ON Time.[Change Number]  = Al.[Associated Change Order Number]
LEFT JOIN Service ON Product.[Change Number]  = Product.[Associated Change Order Number]

WHERE (Time.[Change Area]) Like "*Amr*");
0
 
LVL 19

Assisted Solution

by:frankytee
frankytee earned 500 total points
ID: 21828961
on closer inspection, why are you joining to the Service table on fields from product joined to A1?, ie
LEFT JOIN Service ON Time.[Change Number]  = Al.[Associated Change Order Number]

it should be something like
LEFT JOIN Service ON Time.[Change Number]  = service.whateverFieldThatJoinsToYourTimeTable
0
 

Author Comment

by:pgmtkl
ID: 21867440
i will try the above ways.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now