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');

猜你喜欢

转载自www.cnblogs.com/boshen-hzb/p/9060740.html