需要帮助......
我有这样的表
date_id hour_id value_1
2012-11-03 1 90.7942
2012-11-03 2 113.441
2012-11-03 3 107.419
2012-11-03 4 89.418
2012-11-03 5 86
2012-11-03 6 103.283
2012-11-03 7 96.5645
2012-11-03 8 98.0877
2012-11-03 9 95.0196
2012-11-03 10 95.7386
2012-11-03 11 94.0219
2012-11-03 12 99.8164
2012-11-03 13 96.867
2012-11-03 14 93.5112
2012-11-03 15 99.4857
2012-11-03 16 92.5523
2012-11-03 17 97.2775
2012-11-03 18 91.7806
2012-11-03 19 93.3862
2012-11-03 20 89.3597
2012-11-03 21 96.96
2012-11-03 22 98.0562
2012-11-03 23 96.6908
date_id& hour_id为高图的CATEGORY
其中午12:00不存在..
what i want to do is still show the date
|date_id | hour_id | value_1 |
|2012-11-03 | 0 | |
|2012-11-03 | 1 | 90.7942 |
|2012-11-03 | 2 | 113.441 |
|2012-11-03 | 3 | 107.419 |
|
|
|
.....
我想用PHP和highcharts验证它... 请帮助你 抱歉我的英文不好
更新
我用于此的查询:
$ d1 ='2012-11-02'; $ d2 ='2012-11-03';
$ sql =“SELECT distinct MSC 来自
scrkpi_h
MSC在哪里'MSPLG%' AND descr = 32“; $ query_n = mysql_query($ sql);
while($ ret_n = mysql_fetch_array($ query_n)) { $ nodes = $ ret_n [0]; $ nodes_l [] = $ ret_n [0]; }while(strtotime($ d1)< = strtotime($ d2)) {
为($ H = 0; $ H< 24; $ H ++) { $ query = mysql_query($ sql);
while($ ret = mysql_fetch_array($ query)) {$q1 = mysql_query("SELECT value FROM scrkpi_h WHERE date_id = '$d1' AND hour_id = '$h' AND msc = '$ret[0]' AND descr='32'"); while($scr=mysql_fetch_array($q1)) { echo "$ret[0] $d1 $h $scr[0]"; echo "<br>"; } } } $d1 = date ("Y-m-d", strtotime("+1 day", strtotime($d1))); }
我正在使用此循环($ h = 0; $ h&lt; 24; $ h ++)来验证表格。 但如果表没有* hour_id *,我循环它返回空。
答案 0 :(得分:0)
我不喜欢的东西,这不应该是诀窍:
SELECT table.* FROM table ...
UNION
SELECT '2012-11-03', '', ''
如果您需要更好的答案解释更多 - 您正在使用的确切查询是什么,您希望有时会为“12:00”等等设置值...
答案 1 :(得分:0)