zend_db_select 使用 3 个或更多表进行连接
所以 Zend_db_select 有方法
`joinUsing(table, join, [columns]) and joinInnerUsing(table, join, [columns])`
`joinLeftUsing(table, join, [columns])`
`joinRightUsing(table, join, [columns])`
`joinFullUsing(table, join, [columns])`
等,
但是如果你想连接 3 个或更多表(例如,多对多关联)怎么办......例如:这个查询:
SELECT * FROM (j LEFT JOIN e ON j.id = e.eee) LEFT JOIN w ON w.www = e.id
你会如何用 zend_db_select 来做到这一点
So Zend_db_select has the methods
`joinUsing(table, join, [columns]) and joinInnerUsing(table, join, [columns])`
`joinLeftUsing(table, join, [columns])`
`joinRightUsing(table, join, [columns])`
`joinFullUsing(table, join, [columns])`
etc
but what if you want to join 3 or more tables (eg for a many to many association)....eg: this query:
SELECT * FROM (j LEFT JOIN e ON j.id = e.eee) LEFT JOIN w ON w.www = e.id
how would you go about doing this with zend_db_select
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试做...但我不太确定是否可以使用两个字段,但还没有尝试过使用
您尝试构建查询的3个字段,并且您也可以通过
die((string)$select) 检查查询
Try doing ... but i am not so sure works with two fields but have not tried with 3 fields
you try to build query, and also you can check query by
die((string)$select)
尝试使用子查询和 Zend_Db_Expr。点击此处了解更多信息。
Try use subquery and Zend_Db_Expr. Read more here.