查询表达式中的语法错误(缺少运算符)''

时间:2015-06-15 08:26:13

标签: sql vb.net ms-access-2010

我现在已经发现这个特殊错误几个小时了,我仍然无法弄清楚我的生活中我的选择陈述有什么问题,我试图连接3个表。

"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 个答案:

答案 0 :(得分:3)

此位置不需要examples/cherry个关键字(位于AND前面)。如果您将其删除并在INNER JOIN周围添加括号,则您的查询应该有效:

LEFT JOIN

顺便说一下,不要在字符串中包含"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" 的值,而是使用Parameters以避免SQL注入攻击。