Solved

Query working in SQL Server not working in MS-Access

Posted on 2009-05-18
11
169 Views
Last Modified: 2013-11-07
Hi Experts,
I am having my database in MS Access(I haven't work with access earlier),I write a simple join statement to retrieve data from tables but surprisingly it is throwing Syntax error.
So I created those tables in Sql and execute the same query and it is working fine there.
Is there syntax differences in Sql and Access.
If so then what should I change in following query,


select PM.Prod_Name,NV.Visit_Count,ST.Quantity,RT.Prod_Code as 'Rejection Reason'

 from

 Product_Master PM

 inner join Next_Visit NV on NV.Prod_Code=PM.Prod_Code

 left outer join Sale_Table ST on ST.Prod_Code=PM.Prod_Code

 left outer join Rejection_Table RT on RT.Prod_Code=PM.Prod_Code

Open in new window

0
Comment
Question by:johny_bravo1
  • 6
  • 4
11 Comments
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24418523
Kindly try this one out in Access, A slight change in syntax
select PM.Prod_Na,NV.Visit_C,ST.Quantit,RT.Prod_Co as "Rejection Reason"

from

Product_Master PM

inner join Next_Visit NV on NV.Prod_Co = PM.Prod_Co

left outer join Sale_Table ST on ST.Prod_Co = PM.Prod_Co

left outer join Rejection_Table RT on RT.Prod_Co = PM.Prod_Co;

Open in new window

0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 24418538
Thanks rrjegan17 but getting same error.

Error::

Syntax Error (Missing Operator)  in query expression 'NV.Prod_Code=PM.Prod_Code
 left outer join Sale_Table ST on ST.Prod_Code=PM.Prod_Code
 left outer join Rejection_Table RT on RT.Prod_Code=PM.Prod_Cod'
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24418567
Ok.. Try this one out
select Product_Master.Prod_Na,Next_Visit.Visit_C,Sale_Table.Quantit,Rejection_Table.Prod_Co as "Rejection Reason"

from Product_Master

inner join Next_Visit on Next_Visit.Prod_Co = Product_Master.Prod_Co

left outer join Sale_Table on Sale_Table.Prod_Co = Product_Master.Prod_Co

left outer join Rejection_Table on Rejection_Table.Prod_Co = Product_Master.Prod_Co;

Open in new window

0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 24418585
:(  still the same error
0
 
LVL 9

Accepted Solution

by:
tculler earned 400 total points
ID: 24418599
I'm fairly certain MS Access doesn't support the "outer" keyword. I may be wrong, but this should work.

Hope it helps,
Nate
SELECT Product_Master.Prod_Na,Next_Visit.Visit_C,Sale_Table.Quantit,Rejection_Table.Prod_Co AS "Rejection Reason"

FROM Product_Master

INNER JOIN Next_Visit ON Next_Visit.Prod_Co = Product_Master.Prod_Co

LEFT JOIN Sale_Table ON Sale_Table.Prod_Co = Product_Master.Prod_Co

LEFT JOIN Rejection_Table ON Rejection_Table.Prod_Co = Product_Master.Prod_Co;

Open in new window

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Author Comment

by:johny_bravo1
ID: 24418608
Getting same error
Syntax Error (Missing Operator)  in query expression

Can't figure out what is wrong.
0
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 100 total points
ID: 24418745
Can you try this one out:
select Product_Master.Prod_Na,Next_Visit.Visit_C,Sale_Table.Quantit,Rejection_Table.Prod_Co as "Rejection Reason"

FROM Product_Master

inner join Next_Visit on Product_Master.Prod_Co = Next_Visit.Prod_Co

left join Sale_Table on Product_Master.Prod_Co = Sale_Table.Prod_Co

left join Rejection_Table ON Product_Master.Prod_Co = Rejection_Table.Prod_Co;

Open in new window

0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 24418767
didn't work.
Just came across one blog,
http://nm1m.blogspot.com/2007/10/multiple-left-joins-in-ms-access.html

but still trying to achieve.
0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 24418891
select PM.Prod_Name,NV.Visit_Count,ST.Quantity,RT.Prod_Code as "Rejection Reason"
 from
((( Product_Master PM
 Inner Join Next_Visit NV On NV.Prod_Code = PM.Prod_Code)
Left Join Sale_Table ST On ST.Prod_Code = PM.Prod_Code)
 Left Join Rejection_Table RT On RT.Prod_Code = PM.Prod_Code);

The above query works fine.It was the matter of '('.
Thanks for your help.
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24418929
Try this one as mentioned in the site provided.
select PM.Prod_Na,NV.Visit_C,ST.Quantit,RT.Prod_Co as "Rejection Reason"

FROM (((Product_Master AS PM) inner join Next_Visit AS NV on PM.Prod_Co = NV.Prod_Co)

left join Sale_Table AS ST on PM.Prod_Co = ST.Prod_Co)

left join Rejection_Table RT ON PM.Prod_Co = RT.Prod_Co;

Open in new window

0
 
LVL 8

Author Comment

by:johny_bravo1
ID: 24419072
Yup thanks.This too works
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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

17 Experts available now in Live!

Get 1:1 Help Now