gpt4 book ai didi

mysql - 如何在 Zend 语法中进行此 sql 查询

转载 作者:行者123 更新时间:2023-11-29 09:18:17 24 4
gpt4 key购买 nike

我是 Zend Framework 的新用户,我在使用 Zend 语法进行此查询时遇到问题:

SELECT i.*, k.id as id_key, GROUP_CONCAT(DISTINCT k.nome ORDER BY k.id SEPARATOR " ") as tag, GROUP_CONCAT(DISTINCT f.dimensioni ORDER BY f.id SEPARATOR " | ") as formati
FROM immagine i
LEFT JOIN immagine_has_formato fi ON fi.immagine_codice=i.codice
LEFT JOIN formato f ON f.id=fi.formato_id
LEFT JOIN keyword_has_immagine ki ON ki.immagine_codice=i.codice
LEFT JOIN keyword k ON k.id=ki.keyword_id
WHERE i.libro_codice = '06' AND i.codice IN (
SELECT ki.immagine_codice FROM keyword_has_immagine ki
INNER JOIN keyword k ON k.id=ki.keyword_id
WHERE lower(k.nome) = 'steam'
)
GROUP BY i.codice

有谁可以帮帮我吗?谢谢!...

最佳答案

对于子查询,您可以使用此示例作为基础:

...
$subselect = $this->select()->setIntegrityCheck(false);
$subselect->from(array('e'=>'feed_entries'),array('e.id'))
->join(array('f'=>'feeds'),'e.feed_id =f.id','')
->join(array('ec'=>'entries_categorias'),'ec.entry_id =e.id','')
->join(array('c'=>'categorias'),'ec.categoria_id =c.id','')
->where('e.imagem332x332 =?',1)
->where('e.deleted =?',0)
->group('e.id')
->where('c.nome IN(?)',$categories)
->having('COUNT(DISTINCT ec.id) =?',count($categories));

$select = $this->select()->where('id IN ?',$subselect)->order('date DESC')->limit(4);
return $this->fetchAll($select);
...

对于group_concat,我从未尝试过,但是this page评论里有一些例子

此外,请查看 Zend Db Expressions.

关于mysql - 如何在 Zend 语法中进行此 sql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3333401/

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