andyknas
andyknas

Reputation: 1957

Unknown column error in MySQL (#1054)

This sql fails:

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

This works:

select `__kp_RecID` from Levels as l ;

Using MySQL 5.0.77 on some linux variant

Upvotes: 3

Views: 2165

Answers (1)

Daniel Vassallo
Daniel Vassallo

Reputation: 344581

The problem is in your backticks. You should use them as follows:

`r`.`__kp_RecID` 

... instead of:

`r.__kp_RecID`

Test case:

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'

Upvotes: 3

Related Questions