1
votes

I'm getting this particular error for a couple hours now and I still can't figure out for the life of me what's wrong with my select statement, I'm trying to connect 3 tables.

"SELECT POItem.PO AS 'Purchase_Order', POItem.Qty AS 'Quantity', 
POItem.BCurr as 'Currency', POItem.TotalCost, PO.Vendor, Master.Desc1 
FROM PO 
LEFT JOIN POItem ON PO.ID = POItem.PO AND 
INNER JOIN Master ON Master.IPN = POItem.IPN 
WHERE POItem.IPN = '" & TextBox1.Text & "' 
ORDER BY POItem.PO DESC"
1
there is no need of AND before an inner join. - akhil kumar
If you are not familiar with MS Access SQL, it is best to use the query design window. - Fionnuala
@akhilkumar Unfortunately there seems to be another error once i remove the AND. It says Syntax error (missing operator) in query expression 'PO.ID = POItem.PO INNER JOIN Master ON Master.IPN = POItem.IPN'. - Melissa S. Christ
@Fionnuala Will do! Will definitely try out the query design window! - Melissa S. Christ
@akhilkumar I've solved it now! Thanks for the effort! Much appreciated! - Melissa S. Christ

1 Answers

3
votes

There is a AND keyword that is not necessary at this position (just in front of INNER JOIN). If you remove it and add brackets around the LEFT JOIN, your query should work:

"SELECT POItem.PO AS 'Purchase_Order', POItem.Qty AS 'Quantity', 
POItem.BCurr as 'Currency', POItem.TotalCost, PO.Vendor, Master.Desc1 
FROM (PO 
LEFT JOIN POItem ON PO.ID = POItem.PO) 
INNER JOIN Master ON Master.IPN = POItem.IPN 
WHERE POItem.IPN = '" & TextBox1.Text & "' 
ORDER BY POItem.PO DESC"

By the way, instead of including the value of TextBox1.Text in the string, rather use Parameters in order to avoid SQL injection attacks.