Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subquery in UPDATE SQL?
Message
From
16/07/2004 15:04:46
 
 
To
16/07/2004 10:34:10
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00924713
Message ID:
00925310
Views:
21
>>Can you have a subquery in an UPDATE SQL?
>>
>>Brenda
>
>Yes, but I think prior to VFP 9, it can't be a correlated subquery. That is, it can't reference fields from the update table directly.
>
>Tamar

Hi Tamar,

Of course, you can use correlated sub-query in UPDATE in previous VFP versions.
CLEAR 
CREATE CURSOR foo (f1 I, f2 I)
INSERT INTO foo VALUES (1,2)
CREATE CURSOR bar (f3 I, f4 I)
INSERT INTO bar VALUES (1,3)
INSERT INTO bar VALUES (1,4)
INSERT INTO bar VALUES (1,2)
SELECT foo
LIST
UPDATE foo SET f2=f2+1 WHERE f2=(select MIN(f4) from bar WHERE f3=f1)
SELECT foo
LIST
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform