Dungeon wolf
Dungeon wolf

Reputation: 3

Having error while executing postgresqlquery

I am facing error in my query while deleting row from two table which have same primary and foreign key : Query:

DELETE FROM TABLE1 INNER JOIN TABLE2 ON (TABLE1.id=TABLE2.id) WHERE TABLE1.id='21306';

ERROR: syntax error at or near "INNER"

Using rdbms POSTGRESQL

Upvotes: 0

Views: 58

Answers (1)

Vikash Madhow
Vikash Madhow

Reputation: 1344

You can't have a join in the from clause of a delete in Postgresql (although this is supported in SQL Server). Any additional table that you want to participate in the delete must be added to the using clause. Try this instead:

DELETE FROM TABLE1
 USING TABLE2 
 WHERE (TABLE1.id=TABLE2.id) AND TABLE1.id='21306';

Upvotes: 1

Related Questions