sql if else 问题,
select count(point) from (SELECT id as "magazineId",title as "magazineTitle",img_path as "imgPath",point,hits_count from magazine where audit_status='Y' order by point desc Nulls Last) t1
这段sql结果是3,我想实现的是,如果他等于0的话,就查询 别的一段代码,反之就查询
SELECT id as "magazineId",title as "magazineTitle",img_path as "imgPath",point,hits_count from magazine where audit_status='Y' order by point desc Nulls Last这段代码
------解决方案--------------------
示例:
SELECT IF(a1=0,na2,a1) FROM
(SELECT COUNT(POINT) AS a1 FROM (SELECT id AS "magazineId",title AS "magazineTitle",img_path AS "imgPath",POINT,hits_count FROM magazine WHERE audit_status='Y' ORDER BY POINT DESC ) t1) a1,
(SELECT COUNT(*) AS na2 FROM a ) a2
------解决方案--------------------
这逻辑一条qsql完成不了 只能写存储过程 或者程序里判断