我很难弄清楚从哪里开始将此查询放入 Zend_Db_Select。我从未在 Zend 中使用过变量赋值和子查询:
SELECT
@current_continent := stats_geo_continent.id AS `continent_id`,
(SELECT GROUP_CONCAT(code) from stats_geo_country WHERE stats_geo_country.continent = @current_continent) AS `group`,
stats_geo_country.code
FROM
stats_geo_continent
INNER JOIN
stats_geo_country ON stats_geo_country.continent = stats_geo_continent.id;
最佳答案
我认为当您使用 Zend_Db_Expr
进行变量赋值时这是可能的。对于子查询,您可以使用第二个 Zend_Db_Select
对象作为主对象的一部分 - 也许 that link会帮助你的。
关于mysql - Zend_Db_Select 带有变量赋值和子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5014068/