Split record from one column to two column in MysQL or PHP -


i have problem split data attendance machine. data source after export this:

 id name  att 1  john  01/04/2015   7:59:00 1  john  01/04/2015  17:44:00 1  john  02/04/2015   7:50:00 1  john  02/04/2015  18:14 

where record (in , out) fingerprint time save in 1 column. , want split data this:

 id name  in                  out 1  john  01/04/2015 7:59:00  01/04/2015 17:44:00 1  john  02/04/2015 7:50:00  02/04/2015 18:14:00 

how split record 2 column in mysql or php (maybe)? thank you.

assuming there 1 in/out per day, it's simple self-joining on date , greater time.

select t1.id, t1.name, t1.att `in`, t2.att `out`   table1 t1     inner join table1 t2       on date(t1.att) = date(t2.att) , t1.id = t2.id         , t2.att > t1.att 

sql fiddle demo

if want create brand new table data, can rid of import, need use query input create table, so:

create table new_table       select t1.id, t1.name, t1.att `in`, t2.att `out`       table1 t1         inner join table1 t2           on date(t1.att) = date(t2.att) , t1.id = t2.id             , t2.att > t1.att 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -