php - Is a cursor the only way to do this? -


i'm in process of churning through raw data have. data in mysql database. data lists, in millisecond-by-millisecond format, of number of possible 'events' happening. has few columns:

  1. id - unique identifier row
  2. event - indicates event occurring

what basic information regarding these data. specifically, i'd create table has:

  1. the id event starts
  2. the id event ends
  3. a new id indexing events , occurrence, column detailing event happening.

i know easy deal using php, using simple loop through records, i'm trying push boundaries of mysql knowledge bit here (it may dangerous, know!!).

so, question this: cursor best thing use this? ask because events can occur multiple times, doing grouping event type won't work - or it? i'm wondering if there clever way of dealing have missed, without needing go through each row sequentially.

thanks!

to demonstrate commented earlier about, have following table:

event_log   id    int not null auto_increment primary key   start datetime   event varchar(255)                     # or whatever want datatype 

gathering information simple as:

select   el.*,          (select   el_j.start            # -               event_log el_j        #  |              el_j.id > el.id       #  |- grab next row based on next id           limit    1) end             # -     event_log order start; 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -