Weird behaviour with subquery

Started by Christopher Kings-Lynnealmost 22 years ago2 messages
#1Christopher Kings-Lynne
chriskl@familyhealth.com.au

What's going on here:

usa=> select user_id from users_users where joindate >= '2004-03-09';
ERROR: column "user_id" does not exist

usa=> select * from shop_orders where user_id in (select user_id from
users_users where joindate >= '2004-03-09');
[waits and waits and waits...have to cancel]
^CCancel request sent
ERROR: canceling query due to user request

How come using a field that doesn't exist in the subquery actually works
and doesn't cause a syntax error?

Chris

#2Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Christopher Kings-Lynne (#1)
Re: Weird behaviour with subquery

Doh - I think I understand now why this is normal behavior - sorry!

Chris

Christopher Kings-Lynne wrote:

Show quoted text

What's going on here:

usa=> select user_id from users_users where joindate >= '2004-03-09';
ERROR: column "user_id" does not exist

usa=> select * from shop_orders where user_id in (select user_id from
users_users where joindate >= '2004-03-09');
[waits and waits and waits...have to cancel]
^CCancel request sent
ERROR: canceling query due to user request

How come using a field that doesn't exist in the subquery actually works
and doesn't cause a syntax error?

Chris

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match