此查询显示#1248 - 每个派生表必须具有自己的别名

时间:2018-03-31 07:07:17

标签: mysql

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

1 个答案:

答案 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