I have a GROUP_CONCAT using a sub-query however the sub-query is throwing an error 'unknown column m.itemid...'.
I think this maybe a scope issue but i am having major problems finding a solution with my limited knowledge of MySQL. ANy help is appreciated and if you need more information please let me know.
SELECT *,
CASE parent_item_id
WHEN 0 THEN itemid
ELSE parent_item_id
end AS order_items_sort,
(SELECT Group_concat(id)
FROM (SELECT i.install_delivery_id `id`
FROM machine_serials s
INNER JOIN install_delivery_items i
ON s.install_delivery_item_id = i.id
WHERE s.machine_id = m.itemid
GROUP BY i.install_delivery_id) g) `delivery_id`
FROM machines m
WHERE m.orderid = 36549
ORDER BY order_items_sort, parent_item_id ASC