所有栏目:
select typeid ,COUNT(id) from dede_archives WHERE FROM_UNIXTIME( pubdate, '%m' ) = month(curdate( )) and FROM_UNIXTIME( pubdate, '%Y')=2021 group by typeid
河南事业单位地市栏目第二种方式:
SELECT sj.*, dede_arctype.typename from (select count(dede_archives.id) as num,dede_arctype.topid from dede_archives,dede_arctype where dede_arctype.id=dede_archives.typeid and dede_archives.typeid in(15307,15308,15309,15310,15311,15347,15348,15349,15350,15351,15262,15263,15264,15265,15266,15327,15328,15329,15330,15331,15297,15298,15299,15300,15301,15272,15273,15274,15275,15276,15342,15343,15344,15345,15346,15287,15288,15289,15290,15291,15322,15323,15324,15325,15326,15317,15318,15319,15320,15321,15312,15313,15314,15315,15316,15332,15333,15334,15335,15336,15277,15278,15279,15280,15281,15282,15283,15284,15285,15286,15302,15303,15304,15305,15306,15267,15268,15269,15270,15271,15337,15338,15339,15340,15341,15292,15293,15294,15295,15296,) and FROM_UNIXTIME(dede_archives.pubdate, '%Y%m') = CONCAT(year(curdate()),month(curdate())) group by dede_arctype.topid) as sj, dede_arctype where sj.topid=dede_arctype.id