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'
source
share