I'm using MySQL 5.1.66 and I came up with a select query to select all the men's shirts and their sizes and prices. I used GROUP CONCAT
to merge the size column and price column from their parent tables into the same column. Here's the statement I made
SELECT shirts.shirt_name, shirts.men AS main_photo,
GROUP_CONCAT(shirt_sizes.size_name,shirt_prices.price) AS sizes
FROM shirts
JOIN shirts_link ON shirts_link.shirt_id=shirts.id
JOIN shirt_sizes ON shirt_sizes.id=shirts_link.size_id
JOIN shirt_prices ON shirt_prices.id=shirts_link.price_id
WHERE shirts.men!='' AND shirts_link.adult='y'
GROUP BY shirts.id
By doing this, are the size columns and price columns still two separate entities within that one column in the select statement? Another thing I noticed is the order of the sizes is all mixed up. For example, this is a row from one of the columns
medium29.22,large29.22,1x-large29.22,2x-large30.44,small29.22,3x-large31.70
why isn't it going from small-3x like it's organized on the table? I imagine in the event of what I'm trying to do in terms of injecting it into we website through PHP if it were to auto load it would go in that unorganized manner as well. How can I fix this?
My ultimate goal here is to be able to create a selection that can auto populate each row into the javascript apps I created. I need the load the shirt name, main picture, then each size and price into the divs I have coded for them. Let me know if you need to see the actual tables being used. Thanks in advance :)