mysql函数拼接查询concat函数

JAVA学习网 2017-08-04 08:34:02

//查询表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';

阅读(796) 评论(0)