1
是否可以使用CakePHp分頁下面的查詢?Cakephp分條與條款
select u.email,(select count(*) from relatives as iu where iu.user_id=u.id) as iu_count,(select count(*) from friends as ff where ff.user_id=u.id) as ff_count from users as u having (iu_count>0 OR ff_count>0)
我試圖做到這一點使用CakePHP分頁,但它給出了一個錯誤的「iu_count」和「ff_count」不在查詢選擇部分可用,但他們在HAVING子句可用。我的cakephp分頁查詢如下。
SELECT COUNT(*) AS `count` FROM `abc`.`users` AS `User` WHERE 1 GROUP BY `User`.`id` having (iu_count>0 OR ff_count>0)
需要幫助/指導才能使用它。