SQL update statement
Posted in 1994
> > 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 know that I have to do a correlated subquery but I can't figure > out the right syntax. I thought that the example on page 131 of > Jonathan Leffler's book would yield the answer but I haven't been > able to convert his example to my specific case. His example is: > update models > set price = price + 100 + 0.03 * > (select max(hi_price) from prices > where prices.model = models.model > and exists (select * from prices > where prices.model = models.model) > ); > I hope this is enough information. > Thanks I think I got it finally figured out: update file_a set file_a.a2 = "C" where exists (select * from file_b where file_a.a1 = file_b.a1) ~