Quantcast
Channel: Active questions tagged cte - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 207

PSQL cte delete seem have have ambiguity when select same column from delete table

$
0
0

Both these two sql can be execute , the first one delete all , the second one is logic right.

the first one

with d0 as (    delete from seller_create_request        where seller_id in              (                  select id                  from seller                  where email in                        ('xx@xx.com')              )        returning seller_create_request.seller_id)delete from sellerwhere id in (select id from d0)returning  seller.id;

the second one

with d0 as (    delete from seller_create_request        where seller_id in              (                  select id                  from seller                  where email in                        ('xx@xx.com')              )        returning seller_create_request.seller_id)delete from sellerwhere id in (select d0.seller_id from d0)returning  seller.id;

The first one select id from d0 it seem equal to select id from seller.My original intention is select seller_id from d0 but have spell wrong. It don't cause

column id does not exist since it from d0.

So I am strange why psql has this behavior, what I am missing from simple understanding?


Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>