Why is there no aliasing for delete queries?
-
So I can do something like this
select * from table1 t1 where exists (select 1 from table2 t2 where t1.id=t2.id);
I can also do
update t1 set t1.field=5 from table1 t1 where exists (select 1 from table2 t2 where t1.id=t2.id);
But I can't seem to do
delete from table1 t1 where exists (select 1 from table2 t2 where t1.id=t2.id);
I have to do
delete from table1 where exists (select 1 from table2 t2 where table1 .id=t2.id);
which is annoying AF
-
What DBMS are you using? It works fine in Postgres.
-
@sebastian-galczynski said in Why is there no aliasing for delete queries?:
What DBMS are you using? It works fine in Postgres.
SQL Server
-
Actually looking at the docs, looks like this will work
delete from t1 from table1 t1 where exists (select 1 from table2 t2 where t1.id=t2.id)
a little weird with 2 from clauses
-
delete t1 from table1 t1 join table2 t2 on t1.id = t2.id