1

我正在运行此查询

SELECT *  
FROM (`T_INV_DTL`)  
LEFT JOIN 
 (
  SELECT GROUP_CONCAT(DISTINCT T_INV_INVESTIGATOR.Employee_id) AS Employee_id
  FROM T_INV_INVESTIGATOR
  GROUP BY  `T_INV_INVESTIGATOR`.`inv_dtl_id`
  ) ON  `T_INV_DTL`.`inv_dtl_id` =  `T_INV_INVESTIGATOR`.`inv_dtl_id`
JOIN  `T_INVESTIGATION` ON  `T_INV_DTL`.`inv_id` =  `T_INVESTIGATION`.`inv_id` 

它给出了这个错误:

#1248 - 每个派生表都必须有自己的别名

怎么了 ?

4

2 回答 2

2

你必须给子查询一个别名,

检查这个:

SELECT * 
FROM T_INV_DTL T  
LEFT JOIN ( SELECT inv_dtl_id , GROUP_CONCAT( DISTINCT Employee_id ) AS Employee_id 
            FROM T_INV_INVESTIGATOR 
            GROUP BY inv_dtl_id ) A ON T.inv_dtl_id = A.inv_dtl_id 
JOIN T_INVESTIGATION TI ON T.inv_id = TI.inv_id  
于 2013-01-12T05:25:35.767 回答
0

每当您编写子查询时,都必须为 whlole 提供别名

如果您有多个查询,那么最好使用别名在选择列表中给出不同的名称以避免冲突

于 2013-01-12T06:21:24.427 回答