I am trying to figure out how to get (Joomla/Virtuemart) column values into separated columns.
Table: jos_vm_order_item.
MySql 5.0. (can't change it)
I have orders (order_id) and each order has items (order_item_id) from 1 to 3.
order_id order_item_id 1329 1427 1329 1428 1330 1429
I would like to get order_item_id's into separated columns suchs as (order_item_id_1, order_item_id_2, order_item_id_3) as follows
[My objective]
order_id order_item_id_1 order_item_id_2 order_item_id_3 1329 1427 1428 1330 1429
As shown, there is only 2 items in these two orders.
This is what I managed to get working.
SELECT order_id, GROUP_CONCAT(CONVERT(order_item_id, CHAR(8)))
FROM jos_vm_order_item
GROUP BY order_id
order_id order_item_id 1329 1427,1428 1330 1429
However, I need order_item_id's into separated columns [as 'My objective' illustrates].
I would really appreciate if someone could help me about this issue.
I have googled a Lot and I couldn't find out if I could use join for this or not. I can't figure out how to create new columns from the above data.
Best, Jan