GM6
GM6

Reputation: 371

Using alias inside Delete

I'm trying to run the following query (in reality it has more sense but just for the example I made it simple):

DELETE from my_tbl as a where a.id = 0;

But I keep getting

Error: near "as": syntax error.

Is there any way around it? With SELECT * instead of DELETE it worked BTW

Upvotes: 1

Views: 83

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172458

You cannot use alias name for table inside delete statement as delete statement works on single table. Also when you are using single table there seems to be no point of creating an alias. Simply do

DELETE from my_tbl  where id = 0;

Upvotes: 1

Related Questions