DELETE with JOIN (PostgreSQL)
DELETE with JOIN (PostgreSQL) is a SQL statement in the DML Statements category. PostgreSQL: DELETE with USING clause for joins. MySQL uses multi-table DELETE syntax. The syntax is DELETE FROM table1 USING table2 WHERE table1.col = table2.col AND condition;. It returns joined delete. A typical example: -- PostgreSQL: DELETE FROM orders o USING customers c WHERE o.customer_id = c.id AND c.status = 'closed' AND o.created_at < '2025-01-01'; -- MySQL: DELETE o FROM orders o JOIN customers c ON o.customer_id = c.id WHERE c.status = 'closed' AND o.created_at < '2025-01-01'; -- SQL Server: DELETE o FROM orders o JOIN customers c ON o.customer_id = c.id WHERE c.status = 'closed' AND o.created_at < '2025-01-01'; A close relative is INSERT INTO, which inserts new rows into a table. A close relative is UPDATE, which modifies existing rows in a table. Always use WHERE to avoid updating all rows. A close relative is DELETE, which removes rows from a table. Always use WHERE to avoid deleting all rows.