Joined delete

From: Madison Kelly <linux(at)alteeve(dot)com>
To: PgSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Joined delete
Date: 2005-01-03 05:39:38
Message-ID: 41D8DA9A.5050304@alteeve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

After all the great help I got from you all I managed to finish what
I was struggling with. The last thing I need to do should be pretty
simple. :)

I use this query to return values from one table that don't exits in
another table:

SELECT a.fs_name, a.fs_parent_dir, a.fs_type FROM file_set_1 a LEFT JOIN
file_info_1 b ON a.fs_name=b.file_name AND
a.fs_parent_dir=b.file_parent_dir AND a.fs_type=b.file_type WHERE
b.file_name IS NULL;

Which works perfectly. What I need to do though is instead of
returning those value, I need to instead delete the matches. I tried:

DELETE FROM file_set_1 a LEFT JOIN file_info_1 b ON
a.fs_name=b.file_name AND a.fs_parent_dir=b.file_parent_dir AND
a.fs_type=b.file_type WHERE b.file_name IS NULL;

But I am getting the syntax error:

ERROR: syntax error at or near "a" at character 24

This is probably obious... ^.^;

Thank you again!

Madison

Responses

Browse pgsql-general by date

  From Date Subject
Next Message vinita bansal 2005-01-03 07:17:06 function in postgres
Previous Message Tom Lane 2005-01-03 02:31:21 Re: OS X shared memory problems 8.0rc3