How can this SQL be wrong? What am I not seeing?

Posted by ropstah on Stack Overflow See other posts from Stack Overflow or by ropstah
Published on 2010-04-17T23:35:36Z Indexed on 2010/04/17 23:43 UTC
Read the original article Hit count: 182

Filed under:
|
|

Can anybody please spot my error, this should be a legal query in SQL shouldn't it??

Unknown column u.usr_auto_key in the ON clause

This is the database schema:

User: (usr_auto_key, name, etc...)
Setting: (set_auto_key, name etc..)
User_Setting: (usr_auto_key, set_auto_key, value)

And this is the query...

        SELECT 
        `u`.`usr_auto_key` AS `u__usr_auto_key`, 
        `s`.`set_auto_key` AS `s__set_auto_key`, 
        `u2`.`usr_auto_key` AS `u2__usr_auto_key`, 
        `u2`.`set_auto_key` AS `u2__set_auto_key`, 
        `u2`.`value` AS `u2__value` 
        FROM `User` `u`, `Setting` `s` 
        LEFT JOIN `User_Setting` `u2` ON `u`.`usr_auto_key` = `u2`.`usr_auto_key` 
        WHERE (`s`.`sct_auto_key` = 1 AND `u`.`usr_auto_key` = 1 AND admin_property is null)

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql