SELECT * FROM a WHERE id IN (sub query) . When sub query is incorrect . return all rows of table a

From: 逗比请来的猴子 <xh2432(at)vip(dot)qq(dot)com>
To: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: SELECT * FROM a WHERE id IN (sub query) . When sub query is incorrect . return all rows of table a
Date: 2020-06-17 14:56:10
Message-ID: tencent_C931F3C82E827FD2FC5E9E544124FF202E05@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

When I have 2 tables like this&nbsp;
create table test
(
id&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int4,
shapeid&nbsp; &nbsp; &nbsp; &nbsp; int4
);

table testb
(
id&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int4
);

table test has 4 records and table has 1 recors.

sql&nbsp; " select shapeid from testb; "&nbsp; &nbsp; &nbsp;Failed.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

but&nbsp; sql&nbsp; " select * from test where shapeid in ( SELECT shapeid FROM testb ); "&nbsp; return all records of table test&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

sql like this delete all records of my talbe !

Attachment Content-Type Size
image/jpeg 17.6 KB
image/jpeg 14.8 KB
pg_test1.png application/octet-stream 17.6 KB
pg_test2.png application/octet-stream 8.8 KB
pg_test3.png application/octet-stream 7.4 KB
pg_test4.png application/octet-stream 14.8 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2020-06-17 15:10:50 Re: BUG #16496: can't move to next line on Query Editor
Previous Message PG Bug reporting form 2020-06-17 03:07:46 BUG #16496: can't move to next line on Query Editor