SQL语法问题(左连接)
所以我在查询时遇到问题,但我不太明白问题出在哪里。语法错误的地方会加上注释。查询要大得多,我尝试缩短它以进行有效但更整洁的查询。
这是使用 odbc 连接到 Progress 数据库。我听说它使用严格的 SQL-92。
SELECT itemcust."item-cust",
itemcust."cust-no",
corptreeCust.code
FROM pub."item-cust" itemcust
JOIN pub.customer cust
left join pub.salesstructcustomer struct
on ( struct."corp-cust-type" = cust."corp-cust-type"
and struct."corp-cust-num" = cust."corp-cust-num"
)
left join pub.corptree corptreeCust
on ( corptreeCust.uid = struct.corptreeid /* program says SQL Syntax error here */
and corptreeCust.category = 'store'
)
where ( itemcust."in-entity" = {$entity} or itemcust."in-entity" = '*')
and itemcust."item-no" = {$itemno}
and ( itemcust."cust-no" = {$custno} or itemcust."cust-no" = '*')
and cust."cust-no" = {$custno}
谢谢!
So I'm having a problem with a query, and I don't really understand where. A comment is placed where the syntax error is. The query is much larger, I tried to shorten it to make a valid but tidier query.
This is using odbc to connect to a Progress database. I'm told it uses strict SQL-92.
SELECT itemcust."item-cust",
itemcust."cust-no",
corptreeCust.code
FROM pub."item-cust" itemcust
JOIN pub.customer cust
left join pub.salesstructcustomer struct
on ( struct."corp-cust-type" = cust."corp-cust-type"
and struct."corp-cust-num" = cust."corp-cust-num"
)
left join pub.corptree corptreeCust
on ( corptreeCust.uid = struct.corptreeid /* program says SQL Syntax error here */
and corptreeCust.category = 'store'
)
where ( itemcust."in-entity" = {$entity} or itemcust."in-entity" = '*')
and itemcust."item-no" = {$itemno}
and ( itemcust."cust-no" = {$custno} or itemcust."cust-no" = '*')
and cust."cust-no" = {$custno}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
pub.salesstructcustomer
的表别名是struct
,而不是联接中引用的structc
。Your table alias for
pub.salesstructcustomer
isstruct
, notstructc
as referenced in the join.这是一个错字吗?看起来它正在查看 structc 而不是 struct,除非我错过了一些东西。
Is that a typo? Looks like it's looking at structc instead of struct, unless I missed something.
您似乎在 cust 和 itemcust 之间没有 on 子句。这肯定会让解析器感到困惑,从而在查询中进一步抛出错误
You don't seem to have an on clause between cust and itemcust. That could certainly be confusing the parser into throwing an error further down the query
首先,我感谢大家的回应。没有 ON 子句这一事实是一个严重的问题,但实际上并不是真正的问题。
问题实际上是
uid
是一个保留字,我必须将其设为corptreeCust.\"uid\"
=(
First, I appreciate the responses. The fact that there was no ON clause was a serious issue, but it actually wasn't the real problem.
The problem actually was that
uid
is a reserved word, and I had to make itcorptreeCust.\"uid\"
=(