MySQL Forums
Forum List  »  PostgreSQL

Nested query problem - ERROR 1054 (42S22): Unknown column 'users.id' in 'on clause'
Posted by: Joachim Bartosik
Date: July 30, 2010 07:29AM

I had a pretty long query that worked on Postgres but doesn't work on MySQL. (Very) simplified query reproducing my problem is

SELECT * FROM users WHERE EXISTS (SELECT * FROM questions JOIN answers ON answers.owner_id = users.id);

I results in

ERROR 1054 (42S22): Unknown column 'users.id' in 'on clause'

Note: I can make the simplified query work by changing it to

SELECT * FROM users WHERE EXISTS (SELECT * FROM questions JOIN answers WHERE answers.owner_id = users.id);

However that's not possible for my original query - I'm making LEFT OUTER JOIN with a few conditions and select only records where answers.id IS NULL.

In case it matters I'm using MySQL 5.1.46 on Gentoo Linux. Could you help me to fix this?



Edited 1 time(s). Last edit at 07/30/2010 07:32AM by Joachim Bartosik.

Options: ReplyQuote


Subject
Views
Written By
Posted
Nested query problem - ERROR 1054 (42S22): Unknown column 'users.id' in 'on clause'
8396
July 30, 2010 07:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.