mysql - Zend_Db_Select 带有变量赋值和子查询

标签 mysql zend-framework

我很难弄清楚从哪里开始将此查询放入 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/

相关文章:

php - 雅虎老板 - 链接 - 困惑!

php - 如何编写正文中包含 anchor 标记的 Zend Framework URL?

php - zend 框架找不到帮助程序 View 文件。出现 'Plugin by name was not found' 错误

zend-framework - Zend 框架 : How to remove the DtDd Decorator on a Zend_Form_Element_File?

java - spring-xd-batch 作业锁定

mysql - 由于在 MySQL 中使用保留字作为表名或列名而导致的语法错误

mysql - 如何组合查询结果?

mysql - 仅根据第一组值连接两个表

php - 是否有可能从 PHP(使用 ZEND)执行时 INSERTS 被延迟?

mysql - j2ee 中 JDBC 的 SQL 异常问题