Results 1 to 4 of 4

Thread: Mysql error message "Unknown column in on clause"

  1. #1
    Join Date
    Oct 2009
    Posts
    82

    Mysql error message "Unknown column in on clause"

    Hi
    I have recently switched some applications from mysql 4 to mysql 5. Then I found that queries with left outer joins do not work any more. Assume three tables t1, t2, t3 with their corresponding attributes t1.a, t2.b, t3.c. The exact same query worked in Mysql 4, I think this is a valid sql query and does not work in Mysql 5. I am trying the following query please check if this work on your computer.
    Code:
    mysql> select * from t1, t2 left outer join t3 on t1.a=t3.c;
    ERROR 1054 (42S22): Unknown column 't1.a' in 'on clause'
    Any help will be appreciated. Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Mysql error message "Unknown column in on clause"

    Hi
    I think this is the know bug in Mysql 5. If you want to work around this, is to specify t1 join t2 instead of using the ","(comma). the following is the example of this. It worked for me and hopefully will work for you.
    Code:
    create table t1 (a int);
    create table t2 (b int);
    create table t3 (c int);
    
    select * from t1, t2 join t3 on t1.a=t3.c;
    ERROR 1054 (42S22): Unknown column 't1.a' in 'on clause'
    select * from t1, t2 left outer join t3 on t1.a=t3.c;
    ERROR 1054 (42S22): Unknown column 't1.a' in 'on clause'
    select * from t1 join t2 join t3 on t1.a=t3.c;
    //.. this works ..
    select * from t1 join t2 left outer join t3 on t1.a=t3.c;
    //.. this works ..

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Mysql error message "Unknown column in on clause"

    Hello
    I had the same problem, but fortunately it is not a problem for me now and to fix it is a very simple way. All you have to do is just add parentheses to the join after the FROM, as show in the example below
    Code:
    select * from (t1, t2) join t3 on t1.a=t3.c;
    select * from (t1, t2) left outer join t3 on t1.a=t3.c;
    This solution worked on me, and definitely should work for you. This is because MySql has now added some new rules for Sql language. There are more solutions for this, but I think the above is much more easier than others.

  4. #4
    Join Date
    Oct 2009
    Posts
    82

    Re: Mysql error message "Unknown column in on clause"

    Hi,
    Thanks guys.
    I was looking around for this solution, but could not find the way around. Thanks for you guys, both the above solutions work perfectly for me. But just guessing why Sql is changing the rules. Forget it, the solution is working fine and thanks again.

Similar Threads

  1. Replies: 10
    Last Post: 04-11-2011, 10:51 AM
  2. Replies: 5
    Last Post: 19-04-2011, 08:54 AM
  3. Replies: 3
    Last Post: 09-12-2010, 07:09 AM
  4. Replies: 4
    Last Post: 26-06-2010, 04:36 PM
  5. MySql gives "too many transactions" error message
    By Kasper in forum Software Development
    Replies: 4
    Last Post: 29-01-2010, 06:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,993,616.02959 seconds with 16 queries