This topic is locked

update field value (list page)

5/3/2011 1:05:50 PM
ASPRunnerPro General questions
M
mik author

hi...im a newbie with asp and asprunner ... my problem is..
i have outlet table on a list page with outlet no and rate fields..

how can i update or set to zero (0) if rate value is not the highest?
outletno -- rate

outlet1 --- 100

outlet2 --- 400

outlet3 --- 450 ----> highest

outlet4 --- 300
it should look like this after update...
outletno -- rate

outlet1 --- 0

outlet2 --- 0

outlet3 --- 450 ----> highest

outlet4 --- 0
thanks...im hope someone can help me...

Sergey Kornilov admin 5/3/2011

If your database support subqueries you can use the following SQL query to achieve this:

update MyTable set rate=0 where rate < (select max(rate) from MyTable)
M
mik author 5/4/2011

thanks admin...for the reply and i will try the subquery technique...
I wonder can i test for the max rate at add page...and set rate to 0

when rate is not max?

Sergey Kornilov admin 5/4/2011

I think you can use the same query in AfterAdd event.