Skip to content
Advertisement

Postgresql delete multiple rows from multiple tables

Consider 2 or more tables:

I wish to delete all users and their orders that match first name ‘Sam‘. In mysql, I usually do left join. In this example userid is unknown to us.

What is the correct format of the query?

Advertisement

Answer

http://www.postgresql.org/docs/current/static/sql-delete.html

You can also create the table with ON delete cascade

http://www.postgresql.org/docs/current/static/ddl-constraints.html

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement