-----Original Message-----
From: pgsql-general-ow...@postgresql.org
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Alexander Farber
Sent: Friday, October 28, 2011 12:34 PM
To: pgsql-general
Subject: [GENERAL] From select to delete

Hello,

Is there maybe an easy way to delete that player (and all his games and
partners) or do I have to work with temp tables?

---/Original Message------

The easiest way is to create FOREIGN KEY relationships between the various
tables and allow "ON DELETE CASCADE" to do the work.

Otherwise you need to DELETE with an appropriate WHERE clause (and
sub-selects) or you can use the "USING" clause with the DELETE to add
additional condition tables.

DELETE FROM t1
USING (t2 JOIN t3 ON (...)) t_linked
WHERE t1.something = t_linked.something;

See the SQL Command (DELETE) section of the documentation for more details
and examples of DELETE
See the SQL Command (CREATE TABLE ) section of the documentation for
information on how to setup FOREIGN KEYS

David J.




-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to