Reply to Set variable to value in column

Your name:

Reply:


Posted by mcolson on 07/26/07 20:08

Is it possible to set a variable in a stored procedure equal to a
value from a column when that column's respective ID is equal to
max(id)-1


ID A B
1 24 24
2 53 29
3 76 47
4 32 32

What I am trying to do is update A in the last column to be equal to B
from the 4th row, plus A from the 3rd row. If I could set a variable
equal to A in row 3 (in this case 76) I could easily add the variable
to the existing value.

I've tried something like this before. I'm sure some of you will say
right away, "of coarse that doesn't work". I'm new to sql.

Set A = A + select( B from mytable where ID = (select (max(ID)-1) from
mytable))
where ID = (select (max(ID)) from mytable)

Thanks

Matt

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация