SQL advice please
Posted in 2000
Topics: General Discussion
Morning all and Obnoxio,
I am trying to delete some rows from a table where the same columns exist in
another table, but there are two columns to check. I want to delete all rows
in table_a where col_a and col_b are in table_b.
The only way I have so far is as follows
DELETE FROM table_a WHERE trim(col_a)||trim(col_b) IN
(SELECT trim(col_a)||trim(col_b) from table_b)
Does anyone know of a better way?
Thanks
Steve
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
I don't know of the characteristics of your data, but since you have trim() in
the query, I'm guessing that col_a and col_b is character data.
That being the case, trim(col_a) || trim(col_b) might cause you to delete some
rows that you don't mean to. For instance in suppost that the two columns in
table_a are "abc", "defg". Now suppose that in table_b you have a row with
"abcd", "efg". OPPS......
If the columns are the same size in table_a and table_b, perhaps it would be
better not to trim.
Steve Barnes wrote:
> Morning all and Obnoxio,
>
> I am trying to delete some rows from a table where the same columns exist in
> another table, but there are two columns to check. I want to delete all rows
> in table_a where col_a and col_b are in table_b.
>
> The only way I have so far is as follows
>
> DELETE FROM table_a WHERE trim(col_a)||trim(col_b) IN
> (SELECT trim(col_a)||trim(col_b) from table_b)>
> Does anyone know of a better way?
>
> Thanks
>
> Steve
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com