gpt4 book ai didi

sql - 如何在 zend 框架中使用子查询执行查询

转载 作者:行者123 更新时间:2023-11-29 00:58:28 26 4
gpt4 key购买 nike

您好,我需要用 Zend_Db_Select 编写此 sql,但我不知道如何编写子查询。我将不胜感激任何帮助。谢谢。

SELECT * FROM advert WHERE categoryId
IN (
SELECT id
FROM `tree`
WHERE `lft` BETWEEN
(SELECT lft FROM tree WHERE id = '2') AND
(SELECT rgt FROM tree WHERE id = '2'))

最佳答案

// create the main query
$select = new Zend_Db_Select();

//create the subquery
$subSelect = new Zend_Db_Select();

// using the subquery in main query
$select->where('table.field IN(?)', $subSelect->assemble());

关于sql - 如何在 zend 框架中使用子查询执行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4922246/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com