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

It works:

select `__kp_RecID` from Levels as l ;

Using MySQL 5.0.77 for some versions of Linux

+3
source share
1 answer

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'
+3
source

Source: https://habr.com/ru/post/1758241/


All Articles