3

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

4
  • have you tried deleting different parts of the query and then re-testing it to isolate the problem? ie try it with out the WHERE statement, then try it without the second JOIN etc.. Commented Aug 5, 2010 at 16:07
  • Does the equivilent SQL query here also fail? select * from RRICallouts as r, Levels as l JOIN LevelToCalloutsJT as lc on ( r.__kp_RecID = lc._kf_RecID~Callout ) where l.__kp_RecID = 201006221644060009 AND lc._kf_RecID~Level = l.__kp_RecID Commented Aug 5, 2010 at 16:08
  • 2
    I do not envy you having to work on a database with such memorable column names. Is this a Hungarian goulash? Commented Aug 5, 2010 at 16:14
  • 1
    Welcome to SO. +1 for a well-written question: Here's what I'm doing; Here's what I tried; Here's what happened that I don't understand. Meets all the guidelines :-) Commented Aug 5, 2010 at 16:17

1 Answer 1

3

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'
Sign up to request clarification or add additional context in comments.

2 Comments

backticks was the problem. many thanks. the column names are truly messy, but the db name (provided by the host) is even better - 481986_G5ikr6eJy9wmxRm0
I don't envy you that, either!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.