Re: SQL problem - SOS!
Posted in 1999
Topics: General Discussion
No, I forgot that this could be done with sql! Thanks very much for the rapid response. Peter Roy Gvirtsman wrote in message <37773F64.3C4626@informix.com>... >Peter, >how about: > update stockm > set back_order_qty = back_order_qty + 1 > where product = 'WH5204' and warehouse = '02' >or am I missing something ? > >Roy G. >
Convoluted queries like your original update with a sub-query come about when we forget that SQL is NOT a programming (or programmers') language but a USER language. If you think like a programmer you do things like: "I want to update the rows to increase back_order_qty by 1 so I have to select the original value + 1 and set the column to that in the update statement.." So a sub-query flows naturally from the programmer thinking above. But a user would say, more simply: "I want to update the back_order_qty to increase the current value by 1." So that the natural update below flows easily from that straight forward user's statement. Keep this in mind, think like a user, and your SQL will be cleaner. Art S. Kagel Peter Neville wrote: > > No, I forgot that this could be done with sql! > > Thanks very much for the rapid response. > Peter > > Roy Gvirtsman wrote in message <37773F64.3C4626@informix.com>... > >Peter, > >how about: > > update stockm > > set back_order_qty = back_order_qty + 1 > > where product = 'WH5204' and warehouse = '02' > >or am I missing something ? > > > >Roy G. > >