Re: SQL update statement
Posted in 1994
In article <Qmail.201.21885.787509927@gshp9000> hassler@gshp9000.gradsch.ohio-state.edu (Dick Hassler) writes: >In simplistic terms here is what I want to do: > update file_a > set file_a.a2 = "C" > where file_a.a1 = file_b.a1 I'm going to guess that you want to update file_a when the value a1 exists in file_b. In which case you can use: UPDATE file_a SET file_a.a2 = "C" WHERE file_a.a1 IN (SELECT a1 FROM file_b) This is not correlated, but is functionally the same as: UPDATE file_a SET file_a.a2 = "C" WHERE EXISTS (SELECT a1 FROM file_b WHERE file_b.a1 = file_a.a1) which is correlated, but the first one should be much faster. On the other hand, if you are selecting the a1 value from file_b previous to this update statement, you should be storing that value in a variable somewhere and use it thus: UPDATE file_a SET file_a.a2 = "C" WHERE file_a.a1 = a1_variable June ---- June Tong Informix Software ---- ---- junet@informix.com On-Site Regency Support at SAP ---- ---- Informix: (415)926-6140 SAP: (415)286-6808 ----