php - query not perfect to get the required results.? -


mytable-:every 10 seconds data inserted in table depending on page clicked(x,y,z)

page | time | string|  timestamp      x |  0   | load | 2013-07-24 18:45:02     x | 10   | 0    | 2013-07-24 18:45:12     x | 20   | 0    | 2013-07-24 18:45:22     y |  0   | load | 2013-07-24 18:45:25     x | 30   | 0    | 2013-07-24 18:45:32     y | 10   | 0    | 2013-07-24 18:45:35     z |  0   | load | 2013-07-24 18:45:40     x | 40   | 0    | 2013-07-24 18:45:42     y | 20   | 0    | 2013-07-24 18:45:45     z | 10   | 0    | 2013-07-24 18:45:50     x | 50   | 0    | 2013-07-24 18:45:52     y | 30   | 0    | 2013-07-24 18:45:55     x | 0    | load | 2013-07-24 18:45:58     z | 20   | 0    | 2013-07-24 18:46:00     x | 10   | 0    | 2013-07-24 18:46:08     y | 40   | 0    | 2013-07-24 18:46:05 

this trying return query.

x,50      //x page has max time of 50 sec y,40      //y page has max time of 40 sec z,20 x,10      //if groupby,i dont parameter. 

*note:*no of rows returned equal no. of load in string field

here,load indicates page loaded

what doing-:

$query="select field,max(time)" table mytable "this stuck" 

update: there 3 links on page..x,y,z. trying track user activity inserting value every 10 seconds.based on data map graph. users behaviour random(say x y x z x).so need map these changes.on load,time==0 inserted , load in string field inserted.

am clear??

it's easy add 1 more column, let's groupid (int) indicates every new load new group, , increment groupid 1.

example:

groupid | page | time | string|  timestamp  1|    x |  0   | load | 2013-07-24 18:45:02 1|    x | 10   | 0    | 2013-07-24 18:45:12 1|    x | 20   | 0    | 2013-07-24 18:45:22 2|    y |  0   | load | 2013-07-24 18:45:25 2|    x | 30   | 0    | 2013-07-24 18:45:32 2|    y | 10   | 0    | 2013-07-24 18:45:35 3|    z |  0   | load | 2013-07-24 18:45:40 3|    x | 40   | 0    | 2013-07-24 18:45:42 3|    y | 20   | 0    | 2013-07-24 18:45:45 3|    z | 10   | 0    | 2013-07-24 18:45:50 3|    x | 50   | 0    | 2013-07-24 18:45:52 3|    y | 30   | 0    | 2013-07-24 18:45:55 4|    x | 0    | load | 2013-07-24 18:45:58 4|    z | 20   | 0    | 2013-07-24 18:46:00 4|    x | 10   | 0    | 2013-07-24 18:46:08 4|    y | 40   | 0    | 2013-07-24 18:46:05 

after that, can write this:

select     groupid,    field,    max(page)  mytable 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -