我试图以下面的格式从MYSQL查询中获取结果
Date: '2016-01-01', Resource_1: 100, Resource_2: 90, Resource_3:30, Resource_4: 20
Date: '2016-01-02', Resource_1: 0, Resource_2: 20, Resource_3:100, Resource_4: 40
Date: '2016-01-03', Resource_1: 70, Resource_2: 40, Resource_3:0, Resource_4: 50
Date: '2016-01-04', Resource_1: 10, Resource_2: 0, Resource_3:30, Resource_4: 0
我的MYSQL结果采用以下格式:
2016-01-01|Resource_1|100
2016-01-01|Resource_2|90
2016-01-01|Resource_3|30
2016-01-01|Resource_4|20
2016-01-02|Resource_1|0
2016-01-02|Resource_2|20
2016-01-02|Resource_3|100
2016-01-02|Resource_4|40
2016-01-03|Resource_1|70
2016-01-03|Resource_2|40
2016-01-03|Resource_3|0
2016-01-03|Resource_4|50
2016-01-04|Resource_1|10
2016-01-04|Resource_2|0
2016-01-04|Resource_3|30
2016-01-04|Resource_4|0
如何在MYSQL中将其转换为所需的格式。
我想提一下我的表格结构如下:
DATE|RESOURCE_NAME|MARKS
我使用以下查询来获取先前的查询结果
SELECT cd.cd_claim_dt AS cdt,res.res_Name AS NAME,
SUM(CASE WHEN MONTH(cd.cd_claim_dt) = 1 AND YEAR(cd.cd_claim_dt) = 2016 THEN
ct.ct_duration ELSE 0 END) claimed_hrs
FROM
tbl_claim_data cd, tbl_claim_time ct, tbl_resourceinfo res
WHERE
ct.cd_slno = cd.cd_slno AND MONTH(cd.cd_claim_dt) = 1 AND
YEAR(cd.cd_claim_dt) = 2016 AND cd.app_SlNo = 35 AND
cd.res_slno IN(17,22,23,24) AND res.res_SlNo = cd.res_slno
GROUP BY
cd.res_slno, cd.cd_claim_dt, cd.cd_status
ORDER BY
cd.cd_claim_dt
答案 0 :(得分:0)
尝试此查询
if ( !clocks[container]){
clocks[container] = later.setInterval(function () {
setBet(container, instance);
}, timer);}
您还可以使用 concat_ws() instandof concat()功能