SELECT X.workorder_id,X.order_id FROM mr_workorder_data AS X
LEFT JOIN
(SELECT order_id, workorder_id, GROUP_CONCAT(trim_id SEPARATOR '|') AS trim_id_arr
FROM mr_workorder_data
WHERE order_id = X.order_id AND workorder_id =
X.workorder_id GROUP BY order_id)
WHERE X.data_type = 'Accessories' GROUP BY X.workorder_id
答案 0 :(得分:1)
你有一个左连接(subselect)没有别名add(例如:) T在子查询的末尾()
SELECT X.workorder_id,X.order_id
FROM mr_workorder_data AS X
LEFT JOIN ( SELECT order_id,workorder_id,
GROUP_CONCAT(trim_id SEPARATOR '|') AS trim_id_arr
FROM mr_workorder_data
WHERE order_id = X.order_id AND workorder_id = X.workorder_id
GROUP BY order_id ) T
WHERE X.data_type = 'Accessories'
GROUP BY X.workorder_id