Re: wrong query result - Mailing list pgsql-general

From Richard Huxton
Subject Re: wrong query result
Date
Msg-id 47FC7F33.4040405@archonet.com
Whole thread Raw
In response to wrong query result  ("josep porres" <jmporres@gmail.com>)
List pgsql-general
josep porres wrote:
> select clau, lecact-lecant as m3, m3any, ta, tc, 3 as mesos, persones, true
> as clavegueram
> from fac_abonats
> where clau in (select clau from tmp_claus_prova)
> order by clau

> At the end I've realized that there is no column named 'clau'. It has
> another name.

> The question is:
> Is it a normal behaviour? Because I think that if the query is wrong,
> wouldn't be better to raise an error?

It's not an error, you need to be able to refer to columns in the outer
query so you can do:
...(SELECT x FROM tmp_claus_prova WHERE y = clau)

It *is* confusing where you have a typo though. It gets everyone from
time to time.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: "josep porres"
Date:
Subject: wrong query result
Next
From: "Andrus"
Date:
Subject: select statement fails