Re: [GENERAL] DELETE and JOIN

2017-03-14 Thread Alexander Farber
Good morning and thank you for the replies. I've ended up with the following DELETE USING (in order to delete reviews coming from different user id, but same IP address in the last 24 hours): DELETE FROM words_reviews r USING words_users u WHERE r.uid = u.uid

Re: [GENERAL] DELETE and JOIN

2017-03-13 Thread David G. Johnston
On Mon, Mar 13, 2017 at 9:39 AM, Alexander Farber < alexander.far...@gmail.com> wrote: > Good evening, > > In a 9.5 database I would like players to rate each other and save the > reviews in the table: > > CREATE TABLE words_reviews ( > uid integer NOT NULL CHECK (uid <> author)

Re: [GENERAL] DELETE and JOIN

2017-03-13 Thread Adrian Klaver
On 03/13/2017 09:39 AM, Alexander Farber wrote: Good evening, In a 9.5 database I would like players to rate each other and save the reviews in the table: CREATE TABLE words_reviews ( uid integer NOT NULL CHECK (uid <> author) REFERENCES words_users ON DELETE CASCADE, author

Re: [GENERAL] DELETE and JOIN

2017-03-13 Thread Tom Lane
Alexander Farber writes: > ... > However, before saving a review, I would like to delete all previous > reviews coming from the same IP in the past 24 hours: > ... > I have the feeling that the _author_ip variable is not really necessary and > I could use some kind of

[GENERAL] DELETE and JOIN

2017-03-13 Thread Alexander Farber
Good evening, In a 9.5 database I would like players to rate each other and save the reviews in the table: CREATE TABLE words_reviews ( uid integer NOT NULL CHECK (uid <> author) REFERENCES words_users ON DELETE CASCADE, author integer NOT NULL REFERENCES words_users(uid) ON

Re: [GENERAL] Delete from Join

2008-07-04 Thread Gwyneth Morrison
Tom Lane wrote: Gwyneth Morrison [EMAIL PROTECTED] writes: What I am actually trying to get past is: DELETE FROM data_table1 using data_table2 INNER JOIN data_table1 ON data_table1.fkey = data_table2.pkey;

Re: [GENERAL] Delete from Join

2008-07-03 Thread Gwyneth Morrison
Scott Marlowe wrote: Take a look here, in the notes section: http://www.postgresql.org/docs/8.3/interactive/sql-delete.html on the using keyword. Thank you for your reply Scott, I guess this is where the confusion started for me. It says here in your reference that the using clause is

Re: [GENERAL] Delete from Join

2008-07-03 Thread Lennin Caro
--- On Wed, 7/2/08, Gwyneth Morrison [EMAIL PROTECTED] wrote: From: Gwyneth Morrison [EMAIL PROTECTED] Subject: Re: [GENERAL] Delete from Join To: pgsql-general@postgresql.org Date: Wednesday, July 2, 2008, 7:12 PM --- On Wed, 7/2/08, Gwyneth Morrison [EMAIL PROTECTED] wrote

Re: [GENERAL] Delete from Join

2008-07-03 Thread Tom Lane
Gwyneth Morrison [EMAIL PROTECTED] writes: What I am actually trying to get past is: DELETE FROM data_table1 using data_table2 INNER JOIN data_table1 ON data_table1.fkey = data_table2.pkey; The equivalent to that in Postgres would be

[GENERAL] Delete from Join

2008-07-02 Thread Gwyneth Morrison
Hello, Is it possible to use a join keyword in a delete? For example: DELETE FROM data_table1 using data_table2 INNER JOIN data_table1 ON data_table1.fkey = data_table2.pkey; It is not directly mentioned in the delete syntax but the delete refers

Re: [GENERAL] Delete from Join

2008-07-02 Thread Lennin Caro
--- On Wed, 7/2/08, Gwyneth Morrison [EMAIL PROTECTED] wrote: From: Gwyneth Morrison [EMAIL PROTECTED] Subject: [GENERAL] Delete from Join To: pgsql-general@postgresql.org Date: Wednesday, July 2, 2008, 3:15 PM Hello, Is it possible to use a join keyword in a delete? For example

Re: [GENERAL] Delete from Join

2008-07-02 Thread Gwyneth Morrison
--- On Wed, 7/2/08, Gwyneth Morrison [EMAIL PROTECTED] wrote: From: Gwyneth Morrison [EMAIL PROTECTED] Subject: [GENERAL] Delete from Join To: pgsql-general@postgresql.org Date: Wednesday, July 2, 2008, 3:15 PM Hello, Is it possible to use a join keyword in a delete

Re: [GENERAL] Delete from Join

2008-07-02 Thread Scott Marlowe
Take a look here, in the notes section: http://www.postgresql.org/docs/8.3/interactive/sql-delete.html on the using keyword. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] DELETE with JOIN syntax

2005-07-27 Thread Brian Wong
I am currently migrating from MySQL to PostgreSQL and I have found that some queries do not work. For instance, DELETE t1 FROM t1 LEFT JOIN t2 USING (column_id) WHERE t2.column_id IS NULL; works in MySQL. This works as expected even though the MySQL documentation does not mention the option of

Re: [GENERAL] DELETE with JOIN syntax

2005-07-27 Thread Bruno Wolff III
On Wed, Jul 27, 2005 at 15:28:36 -0400, Brian Wong [EMAIL PROTECTED] wrote: I am currently migrating from MySQL to PostgreSQL and I have found that some queries do not work. For instance, DELETE t1 FROM t1 LEFT JOIN t2 USING (column_id) WHERE t2.column_id IS NULL; works in MySQL. This

Re: [GENERAL] DELETE with JOIN syntax

2005-07-27 Thread Stephan Szabo
On Wed, 27 Jul 2005, Brian Wong wrote: I am currently migrating from MySQL to PostgreSQL and I have found that some queries do not work. For instance, DELETE t1 FROM t1 LEFT JOIN t2 USING (column_id) WHERE t2.column_id IS NULL; works in MySQL. This works as expected even though the MySQL

Re: [GENERAL] DELETE with JOIN syntax

2005-07-27 Thread Brian Wong
On 7/27/05, Stephan Szabo [EMAIL PROTECTED] wrote: I think the where t2.column_id is null where column_id is the joining column makes this a form of not exists, so maybe: DELETE FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE t2.column_id = t1.columnid); This looks good. Thanks.