select*from(selectcount(1)as num,monthfrom table1 groupbymonth) A
leftjoin(selectcount(1)as num,monthfrom table1 WHERESTATUS=1groupbymonth) B ON A.month= B.monthwhere a.num = b.num
查询表结构
-- 查询表selectdistinct t.TABLE_SCHEMA ,t.TABLE_NAME as 表名, t.TABLE_COMMENT as 表描述,
t.TABLE_ROWS 数据条数, concat(round(t.DATA_LENGTH/1024/1024,2),'M')as 数据大小
from information_schema.tables t
where t.TABLE_SCHEMA ='dhcs'-- AND t.TABLE_NAME like '%log%' -- AND T.TABLE_COMMENT LIKE '%日志表%'ORDERBY t.TABLE_NAME,t.TABLE_ROWS desc, t.CREATE_TIME desc;-- 查询字段selectdistinct t.TABLE_SCHEMA,t.TABLE_NAME,t.IS_NULLABLE,LOWER(t.COLUMN_NAME), t.COLUMN_NAME,t.COLUMN_TYPE,t.COLUMN_COMMENT
from information_schema.columns t
where t.TABLE_SCHEMA ='dhcs'-- and table_name like '%order%'-- and COLUMN_COMMENT like '%订单表%'-- and LOWER(t.COLUMN_NAME) like '%orderno%'ORDERBY TABLE_NAME;