mysql函数拼接查询concat函数的使用方法


//查询表managefee_managefee的年year 和 month ,用concat函数拼成year-month。例如将2017和1 拼成2017-01。.

 select CONCAT(a.year,'-',if(a.month<=9,CONCAT('0',a.month),a.month))as date,a.* from managefee_managefee as a;  

 //查询managefee_managefee中时间段为2017-01到2017-07的数据 

select * from ( select CONCAT(a.year,'-',if(a.month<=9,CONCAT('0',a.month),a.month))as date,a.* from managefee_managefee as a ) b where b.date between '2017-01' and '2017-07'; 

你可能感兴趣的:(数据库)