我想基于带有RefName字符的e05c%创建表。但是,为什么消息显示字段列表中的RefName不明确?

下面是我的代码:

 DROP TABLE  IF EXISTS TotalZSummary;
 CREATE TABLE TotalZSummary

 SELECT RefName,
        COUNT(CellName) AS CellCount,
        SUM(CellCount*Z_perInst) AS SumZ,
 FROM find_interface c LEFT JOIN
      stdCellVariant v
     ON c.RefName = v.RefName
 WHERE RefName LIKE 'e05c%'
 GROUP BY RefName;


这是我的新代码:

DROP TABLE  IF EXISTS TotalZSummary;
CREATE TABLE TotalZSummary

SELECT
c.RefName,
COUNT(c.CellName) AS CellCount,
SUM(c.CellCount*v.Z_perInst) AS SumZ,
FROM `find_interface` c
LEFT JOIN `stdCellVariant` v ON c.RefName=v.RefName
WHERE c.RefName LIKE 'e05c%'
GROUP BY c.RefName
;


显示的错误是错误-您的SQL语法有错误;在第1行的'FROM find_interface c LEFT JOIN stdCellVariant v ON c.RefName = v.RefName WHER'附近检查与MySQL服务器版本相对应的手册以获取正确的语法。

最佳答案

每当查询中有多个表时,请限定列引用!

SELECT c.RefName, COUNT(c.CellName) AS CellCount,
       SUM(v.CellCountZ_perInst) AS SumZ,
       SUM(v.CellCountUV1_TxTotZ) AS SvtZ,
       SUM(v.CellCountNOM_TxTotZ) AS NomZ,
       SUM(v.CellCountUV2_TxTotZ) AS HvtZ
FROM find_interface c LEFT JOIN
     stdCellVariant v
     ON c.RefName = v.RefName
WHERE c.RefName LIKE 'e05c%'
GROUP BY c.RefName ;


我猜所有其他列都来自stdCellVariant

关于mysql - 如何解决-Error-字段列表中的列'RefName'不明确?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53836117/

10-09 08:47