Re: SQL "update" question
Posted in 1999
Greg Powers wrote: > > Ok, I need to update several fields in a table using values from > another table based on: > 1) equality of TWO fields in each table AND > 2) the value in the second table is not null. > > In pig english, something like: > Update table1 > set table1.age, table1.sex, table1.income = > table2.age, table2.sex, table2.income > where table1.firstname = table2.firstname > and table1.lastname = table2.lastname > (but only do the update if the corresponding field in table2 is not > null, otherwise leave the original value in table1.(age,sex,income) > on a field by field basis. > > Obviously, I've left out the selects. > > Can anyone give me the most efficient way (in SQL) to accomplish this? MOST efficient way? Write a 4GL or ESQL/C program. If written properly, it will fly. Art S. Kagel