Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subquery in UPDATE SQL?
Message
De
15/07/2004 16:28:43
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
15/07/2004 16:19:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00924713
Message ID:
00924906
Vues:
19
Nah .. she got the correct answer anyway.... At least I can admit when I'm wrong..




>Are you going to correct your post to Brenda?
>
>>Thanks... learn something new everyday...
>>
>>
>>
>>>Try this
>>>
>>>------------------------------------------------------------------
>>>* TestUpdateSubQuery.prg
>>>
>>>LOCAL i
>>>
>>>#DEFINE TEST_RECORD 10
>>>
>>>CREATE TABLE TestUpdate FREE ( ;
>>> pkey i( 4 ), ;
>>> datavalue i( 4 ) ;
>>> )
>>>
>>>FOR i = 1 to 10 STEP 1
>>> INSERT INTO TestUpdate ( pkey, datavalue ) ;
>>> VALUES ( i, i )
>>>ENDFOR
>>>
>>>SELECT * FROM TestUpdate
>>>
>>>SELECT * FROM TestUpdate WHERE pkey == TEST_RECORD INTO CURSOR rcurRefUpdate
>>>
>>>UPDATE TestUpdate ;
>>>SET datavalue = GetNewValue() ;
>>>WHERE pkey IN ( ;
>>> SELECT pkey FROM rcurRefUpdate ;
>>> )
>>>
>>>SELECT * FROM TestUpdate
>>>
>>>CLOSE ALL
>>>
>>>RETURN .T.
>>>
>>>
>>>FUNCTION GetNewValue()
>>>
>>>RETURN 25
>>>
>>>----------------------------------------------------------------------
>>>
>>>This is a simple example, but it illustrates that a column in a subset of rows can be updated (to a single value) in this fashion.
>>>
>>>Hope this helps,
>>>
>>>John
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform