這是我的表emp的兩列,我試圖在我的動態Web應用程序(servlet,jsp)中激發2個單獨的查詢,其中Id能夠從表中獲取我的數據;mysql中的時間和日期劃分
+-------------------------+----------+
| date | serialNo |
+-------------------------+----------+
| 2012-11-21 15:14:08.323 | 6 |
| 2012-11-21 12:48:12.067 | 6 |
| 2012-11-21 09:00:16.559 | 8 |
| 2012-11-21 05:24:20.091 | 9 |
| 2012-11-21 01:11:24.413 | 6 |
| 2012-11-21 14:57:28.531 | 11 |
| 2012-11-21 17:04:31.86 | 9 |
| 2012-11-21 19:33:36.259 | 13 |
| 2012-11-21 20:21:40.524 | 9 |
| 2012-11-21 23:00:44.362 | 8 |
| 2012-11-21 00:24:53.613 | 11 |
我想,不論日實施
鴻溝的時候喜歡
Time Division | Count
| 00:00:00 - 05:59:59 | 3
| 06:00:00 - 11:59:59 | 1| 12:00:00 - 17:59:59 | 4
查詢:select date count(*) as Count from info where (date between '%00:00:00%' and '%05:59:59%' or date between '%06:00:00%' and '%11:59:59%' or date between '%12:00:00%' and '%17:59:59%') group by date.
:(:(
我發現我根本接近:(我的查詢任何這一點,所以我提出這個這個forum.Any樣。在這個方面的投入會受到歡迎
在那裏,我想你想在時間上進行數學劃分:)。 「GROUP BY」似乎是解決您的問題的方法。 – Mr47
其實我想分時間。 –
請顯示您已有的查詢,這可能會有所幫助。另外,對於你所遇到的問題,你需要像'GROUP BY(ROUND(HOUR(dateField)/ 6)* 6)'這樣的東西。這不是真正的代碼,只是概念... – Mr47