首先,即時使用SQL將數據隔離到3個不同的時間(24小時)框架。只有SQL查詢語言。我正在使用MYSQL工作臺來提取我的項目所需的一些功能。我設法提取所需的功能,並將其存儲在新的表格中調用新事件。我也將時間轉換爲整數。以下是所使用的SQL代碼: -如何使用MYSQL
select iphdr.cid ,iphdr.ip_dst, date(event.timestamp), convert(time(event.timestamp), unsigned) as newtime, event.signature
from iphdr, event
where iphdr.cid = event.cid
order by event.signature;
結果(某些輸出的)
cid |ip_add |date |newtime|sig. 480 | 3232284675 | 2011-11-19 |4328 | 1 482 | 3232284675 | 2011-11-19 |4328 | 1 1 | 3232284675 | 2011-11-19 |113928 | 1 2 | 3232284675 | 2011-11-19 |235959 | 2
由於我已經轉換的時間爲數字;因此,新時間,現在我需要在24小時內(時間框架0,1和2)將上述查詢的輸出分隔爲三個不同的時間範圍。這是問題....當我嘗試使用代碼(下面)時,我不斷收到1064錯誤代碼。我認爲通過使用IF然後Else,我可以很容易地將數據分成3個不同的時間範圍。 我需要的輸出就像下面
cid |ip_add |date |newtime|sig. |time Frame 480 | 3232284675 | 2011-11-19 | 4328 | 1 | 0 482 | 3232284675 | 2011-11-19 |4328 | 1 | 0 1 | 3232284675 | 2011-11-19 |113928 | 1 | 1 2 | 3232284675 | 2011-11-19 |235959 | 2 | 2
下面是我所用想做到這一點的代碼,但是我不斷收到錯誤代碼1064
select newtime from new_event for every row
IF newtime < 80101
than newtime = 0
else if newtime > 80000 and newtime < 160101 than newtime = 1
else if newtime >160000 than newtime = 2
end if
我希望IM做更有意義。當談到編程時,我是一個完整的klutz。對不起 。我也試圖通過瀏覽網絡使這項工作。在等待你的回覆時,我會努力工作。
謝謝你,所以非常。我終於明白了。我現在可以去睡覺了。 – user1092074
不,這是錯誤的語法,只是從new_event選擇if(newtime> 160000,2,if(newtime> 80000,1,0))作爲time_frame;' – ajreal