Wednesday 15 April 2015

Turn 3 column table in 2-dimensional matrix in MySQL -



Turn 3 column table in 2-dimensional matrix in MySQL -

i have table looks this:

color | size | deliverytime -------------------- reddish | s | 1 reddish | m | 3 reddish | l | 5 black | s | 2 black | m | 4 black | l | 6

i table transform this:

s | m | l --------- reddish 1 | 3 | 5 black 2 | 4 | 6

the background is: delivery time for, say, t-shirt, different, depending on color , size. not every color available in every size , sizes not fixed, e.g. womens sizes start @ 36,38,40 instead of s, m, l. puzzles me here how turn values of first table dynamically column captions of second.

the list of valid values sizes big create big table out of it.

i in mysql, e.g. function. other alternative can think of doing in language, since output in html. don't know how should google this.

what trying there if right grouping color , size. can same info adding group color, size @ end of query. can format info when outputting html.

to of sql may want avoid looking @ in terms of info matrix.

mysql table matrix

No comments:

Post a Comment