Page 1 of 1

DELETE using JOIN, is that possible in Vertica?

Posted: Sun May 05, 2013 4:22 pm
by jagadeesh
Can we DELETE records based on JOIN.

that is delete records which are common between the tables.

Ex:

Delete from table_A join table_b
on a.col1=b.col1;

i am getting an error 4856: Syntax error at or near "join"

Re: DELETE using JOIN, is that possible in Vertica?

Posted: Tue May 07, 2013 1:22 pm
by JimKnicely
Hi!

You must have been using MySQL where that syntax is ok :)

This DELETE statement will do the same thing in Vertica:

Code: Select all

DELETE FROM table_A 
 WHERE EXISTS (SELECT NULL
                 FROM table_b 
                WHERE table_b.col1 = table_A.col1);
Please make sure to test it!

Re: DELETE using JOIN, is that possible in Vertica?

Posted: Tue May 07, 2013 6:46 pm
by jagadeesh
Oh ya... co-related...

Thanks... this works...