Wondering if someone can show me the correct syntax of a delete
statement where I want to delete rows from table 'A' where say column1
of table 'A' = column 1 of table 'B' and column 2 of table 'A' = column
2 of table 'B'. Working within a procedure and would like to do
something cleaner than having to create a cursor. I'm sure there
example but not sure exactly what to search for!
Thanks,
JeffThis should give you something to think about.
DELETE FROM A
WHERE EXISTS
(SELECT * FROM B
WHERE A.col1 = B.col1
AND A.col2 = B.col2)
Roy Harvey
Beacon Falls, CT
On 4 Jan 2007 15:20:55 -0800, "jeff" <jeffa@.telect.com> wrote:
>Wondering if someone can show me the correct syntax of a delete
>statement where I want to delete rows from table 'A' where say column1
>of table 'A' = column 1 of table 'B' and column 2 of table 'A' = column
>2 of table 'B'. Working within a procedure and would like to do
>something cleaner than having to create a cursor. I'm sure there
>example but not sure exactly what to search for!
>Thanks,
>Jeff|||Here's an interesting twist of the DELETE statement syntax that I ran across
not too long ago...
DELETE FROM TableA FROM TableB
WHERE TableA.Column1 = TableB.Column1 AND
TableA.Column2 = TableB.Column2 AND
TableA.Column3 = TableB.Column3
The double FROMs look weird, but it's valid syntax and it even works.
Regards,
Jerry
"jeff" wrote:
> Wondering if someone can show me the correct syntax of a delete
> statement where I want to delete rows from table 'A' where say column1
> of table 'A' = column 1 of table 'B' and column 2 of table 'A' = column
> 2 of table 'B'. Working within a procedure and would like to do
> something cleaner than having to create a cursor. I'm sure there
> example but not sure exactly what to search for!
> Thanks,
> Jeff
>
No comments:
Post a Comment