Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UPDATE the same field twice in one statement
Message
De
07/11/2009 13:58:37
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01433681
Message ID:
01433691
Vues:
40
Wouldn't adding a SELECT into the UPDATE slow down the update considerably? Why the syntax you posted in your first reply would not work? Here is what I was trying to do. I wanted to reduce the value in field MYFLD1 by some calculated value of nValue1 but not to set it below 0. Then I wanted to increase the value in field MYFLD1 by some other calculated value of nValue2. I think maybe you changed the syntax because function MAX() in SQL Server takes only one parameter (is this the case?)?


>The correct (working) way to do that
>
>
>UPDATE mytable ;
>		SET myfld1 = (SELECT MAX(myfld1) FROM mytable WHERE Pk = nPkValue)  - nValue1 + nValue2 ;
>	WHERE Pk = nPkValue
>
>
>>How come I didn't think of that? <g> Thank you very much.
>>>You can do it in one update
>>>
>>>
>>>UPDATE MYTABLE SET MYFLD1 = MAX(MYFLD1 - nValue1) + nValue2 WHERE Pk = nPkValue
>>>
>>>>
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform