Search Postgresql Archives

Re: From select to delete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----Original Message-----
From: pgsql-general-owner@xxxxxxxxxxxxxx
[mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of Alexander Farber
Sent: Friday, October 28, 2011 12:34 PM
To: pgsql-general
Subject:  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@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux