波神

导航

mysql CONCAT用法

1、全表查询

SELECT * FROM `wh_statistics_service_api_request`;

由于上面时间是按year,month,day三个数值字段来存时间的,现在想通过时间段查询,可以用concat将三个字段拼接

SELECT CONCAT(t1.year,'-',t1.month,'-',t1.day) as accessDate, t1.total_request_count as accessCount FROM wh_statistics_service_api_request t1, wh_bu_service t2 where t1.service_id=t2.service_id  AND date(CONCAT(t1.year,'-',t1.month,'-',t1.day)) <date('2018-5-19');

 

posted on 2018-05-19 16:34  波神  阅读(469)  评论(0编辑  收藏  举报