php - Mysql dynamic rows to columns -
php - Mysql dynamic rows to columns -
layout
https://www.dropbox.com/s/6fu81cqsl25vksd/layout.png?dl=0
link image
example:
create statement:
create table rating ( id int, tieid int, inspected datetime, rate varchar(50) ); insert statement:
insert rating values (1,1, '0000-00-00 00:00:00', 'e'), (2,1, '2015-03-31 01:01:22', 'g'), (3,1, '2015-02-26 01:01:22', 'b'), (4,2, '0000-00-00 00:00:00', 'e'), (5,2, '2015-03-31 01:01:22', 'f'); what im trying ouput info such cant seem figure out how query right this
tieid | inspected1 | rate1| inspected2 | rate2| inspected3 | rate3| 1 | 0000-00-00 |e |2015-02-26 |b | 2015-03-31 |g | 2 | 0000-00-00 |e |2015-03-31 |f | | | -------------------------------------------------------------------
doing in single query, not possible in mysql, because mysql not have feature that.
on page there's suggestion might doable using prepared statements, , dynamic query generations: mysql pivot table query dynamic columns
in opinion, approach pretty wtfey , not utilize , take multiple query approach instead.
php mysql
Comments
Post a Comment