Re: How to update a field with a return of a select in SE 4.0
Posted in 1997
>From: casfra01@pd.nettuno.it (casfra01) >Date: 5 Feb 1997 18:19:46 GMT >X-Informix-List-Id: <news.33480> > >Can I update a field with a return of a select? For example : > >" Update table1 > set table1.field1 = (select table2.field2 > from table2 > where table2.filed3 = table1.filed3)" Yes, but make sure you have a WHERE clause on the main UPDATE too. If you don't you'll update every row in Table1, and those rows for which there isn't an entry in Table2 will be set null. This is not what you want, in general. Your syntax is pretty much correct; you may not be able to use table.column notation on the LHS of the SET clause. You can also update sets of columns using the notation: SET (col1, col2, col3) = ((SELECT ColA, ColB FROM ...), (SELECT ColC...)) Have fun! Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>