Solved

ACCESS SQL 'Syntax error in FROM clause' - Can you help me find the bug?

Posted on 2013-06-07
8
465 Views
Last Modified: 2013-06-12
The following SQL Statement apparently has a typo.  I can't find it though.  It should be an easy 500 points.  Here it is (remember it is Access):
SELECT DISTINCT VA.CallerID AS Client_ID, VB.[Date] AS Encounter, '1' AS Opt 
FROM ((((qry_Disability_Referral_Counts AS VA 
INNER JOIN qry_CallLog_Rel_CallType AS VB ON VB.Caller = VA.CallerID) 
INNER JOIN qry_Calls_Rel_Vet_Services AS VV On VV.Call_ID = VB.Call_ID) 
LEFT OUTER JOIN qry_War_Counts AS VW On VW.callerid = VA.CallerID) 
LEFT OUTER JOIN qry_Race_Counts AS VR On VR.callerid = VA.CallerID) 
LEFT OUTER JOIN qry_VA_Referral_ Counts AS VC ON VC.callerid = VA.CallerID 
WHERE VB.Call_Type_ID = 2 
UNION ALL 
SELECT DISTINCT VA.CallerID AS Client_ID, VB.[Date] AS Encounter, '0' AS Opt 
FROM ((((qry_Disability_Referral_Counts AS VA 
INNER JOIN qry_CallLog_Rel_CallType AS VB ON VB.Caller = VA.CallerID)
INNER JOIN qry_Calls_Rel_Vet_Services VV On VV.Call_ID = VB.Call_ID) 
LEFT OUTER JOIN qry_War_Counts AS VW On VW.callerid = VA.CallerID) 
LEFT OUTER JOIN qry_Race_Counts AS VR On VR.callerid = VA.CallerID) 
LEFT OUTER JOIN qry_VA_Referral_Counts AS VC ON VC.callerid = VA.CallerID 
WHERE VB.Call_Type_ID <> 2;

Open in new window

0
Comment
Question by:David L. Hansen
  • 4
  • 4
8 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 39230258
I would start by removing all the parentheses
0
 
LVL 15

Author Comment

by:David L. Hansen
ID: 39230304
It's Access.  It is a requirement when working with multiple joins....see this link:
http://nm1m.blogspot.de/2007/10/multiple-left-joins-in-ms-access.html
I know...weird huh?
0
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 39230315
Ok, then it looks like you are missing a set for the final query in each part of your union
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 18

Expert Comment

by:UnifiedIS
ID: 39230346
Are you able to use the Design view to build this query?  It doesn't look too complicated to create and then you can use the SQL view to see exactly what Access wants.
0
 
LVL 15

Accepted Solution

by:
David L. Hansen earned 0 total points
ID: 39230356
Found it.  There is an extra blank in the table name in the last LEFT OUTER JOIN (before the UNION ALL) just after one of the underscores. Wheew! Thanks though!
0
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 39230360
I also notice in the link you provided that the first table is contained within parentheses but in your queries, they are not.

I think the from would then look like this with a 5th "(" and the ")" after the VA alias

FROM ((((qry_Disability_Referral_Counts AS VA)
0
 
LVL 15

Author Comment

by:David L. Hansen
ID: 39235407
You'd think huh?  But just changing that one space made the whole thing work superbly...go figure.
0
 
LVL 15

Author Closing Comment

by:David L. Hansen
ID: 39240448
Found the bug on my own.  Very grateful for someone looking at it with me though.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ms sql + get number in list out of total 7 29
Increment column based of a FK 8 23
Display <> "Yes" records 10 10
Modify report 8 8
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 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