代码之家  ›  专栏  ›  技术社区  ›  andyknas

MySQL中的未知列错误(#1054)

  •  3
  • andyknas  · 技术社区  · 14 年前

    select * from RRICallouts as r 
        JOIN LevelToCalloutsJT as lc on ( `r.__kp_RecID` = `lc._kf_RecID~Callout` ) 
        JOIN Levels as l ON ( `lc._kf_RecID~Level` = `l.__kp_RecID` ) 
      where `l.__kp_RecID` = 201006221644060009
    
    #1054 - Unknown column 'l.__kp_RecID' in 'where clause
    

    这样做有效:

    select `__kp_RecID` from Levels as l ;
    

    1 回复  |  直到 14 年前
        1
  •  3
  •   Daniel Vassallo    14 年前

    `r`.`__kp_RecID` 
    

    ... 而不是:

    `r.__kp_RecID`
    

    测试用例:

    CREATE TABLE test (id int, value int);
    INSERT INTO test VALUES (1, 100);
    
    SELECT `t`.`id` FROM test AS t;
    +------+
    | id   |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)
    
    SELECT `t.id` FROM test AS t;
    ERROR 1054 (42S22): Unknown column 't.id' in 'field list'