Zend DB:joinLeft 问题
我正在尝试使用 Zend DB 构建此查询:
SELECT
`s` . * ,
`a` . *
FROM
`shr_statement` AS `s`
LEFT JOIN
`shr_answer` AS a`
ON
a.statement_id = s.statement_id
AND
a.user_id =1
WHERE
(s.language = 'en_US') AND (s.is_active =1 )
ORDER BY
`order` ASC
我读到了有关双“ON”语句的可能问题...
谢谢!
I am trying to construct this query with Zend DB:
SELECT
`s` . * ,
`a` . *
FROM
`shr_statement` AS `s`
LEFT JOIN
`shr_answer` AS a`
ON
a.statement_id = s.statement_id
AND
a.user_id =1
WHERE
(s.language = 'en_US') AND (s.is_active =1 )
ORDER BY
`order` ASC
I read about a possible issue with the double 'ON' statement ...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以解决问题,其中 $db 是 Zend_Db 适配器的实例
This should do the trick, where $db is an instance of your Zend_Db adapter
看来您缺少别名中的左反引号..即它应该是“
shr_answer
ASa
”。或者最好去掉所有的反引号。他们是邪恶的,也是不必要的! ;)
It seems you're missing the left backtick from your alias.. ie it should be "
shr_answer
ASa
".Or even better get rid of all your backticks. They are evil and unnecessary! ;)