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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -