From: | selva kumar <selva(dot)logic(at)hotmail(dot)com> |
---|---|
To: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
Cc: | "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | RE: Query will execute when inner query have issue |
Date: | 2020-01-23 15:51:56 |
Message-ID: | MAXPR01MB21577DB26C2E9CBF67314BB5E20F0@MAXPR01MB2157.INDPRD01.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Greetings
I did the following excise.
CREATE TABLE product(
productid int PRIMARY KEY,
productname CHARACTER VARYING NOT NULL);
INSERT INTO product values (1,'Pen');
INSERT INTO product values (2,'Pencil');
CREATE TABLE sales(
salesdate date,
product int,
qyt int);
INSERT INTO sales VALUES ('2020-01-22',1,10);
INSERT INTO sales VALUES ('2020-01-22',2,20);
select productid from sales where salesdate='2020-01-22';
ERROR: column "productid" does not exist
LINE 1: select productid from sales where salesdate='2020-01-22'
But the following query will executed
select * from product where productid in (select productid from sales where salesdate='2020-01-22')
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
________________________________
From: Daniel Gustafsson <daniel(at)yesql(dot)se>
Sent: Thursday, January 23, 2020 3:25:53 PM
To: selva kumar <selva(dot)logic(at)hotmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Query will execute when inner query have issue
> On 23 Jan 2020, at 08:34, selva kumar <selva(dot)logic(at)hotmail(dot)com> wrote:
>
> Greetings,
>
> We tried query in a following manner.
>
> SELECT * FROM A where A.id IN (SELECT B.id from B);
>
> In the above query Table B does not have id. But this query return all A table records
>
> Note : If we run inner query alone, It throws error like “Field is not found”
This is not reproducible for me, it fails as expected:
db=# select * from a where a.id in (select b.id from b);
ERROR: column b.id does not exist
LINE 1: select * from a where a.id in (select b.id from b);
^
HINT: Perhaps you meant to reference the column "a.id".
Which version of postgres are you using, and how are you executing the query?
cheers ./daniel
From | Date | Subject | |
---|---|---|---|
Next Message | selva kumar | 2020-01-23 15:52:12 | RE: Query will execute when inner query have issue |
Previous Message | Alvaro Herrera | 2020-01-23 15:48:03 | Re: 12.1 Partitioned Table Creation Bug |