Solved

Query working in SQL Server not working in MS-Access

Posted on 2009-05-18
11
172 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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