Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you do an UPDATE like this?
Message
 
To
23/02/2000 10:50:40
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00336023
Message ID:
00337553
Views:
15
John sez:
>You cannot use JOIN in an UPDATE in either VFP or SQL Server (Can't figure out which you are trying). UPDATEs are for a single table only.

Chuck sez:
Oh yes you can! Well, at least in SQL you can. VFP can do it in a different way.

SQL Server is entry-level SQL-92 compliant; therefore, you can use a FROM clause, like this:

USE Northwind

UPDATE products
SET unitprice = unitprice + 2
FROM products JOIN suppliers
ON products.supplierid = suppliers.supplierid
WHERE suppliers.country = 'USA'

In VFP, you CAN use a SubQuery to "join" tables:
UPDATE products
SET unitprice = unitprice + 2
WHERE supplierid IN
(SELECT supplierid FROM suppliers WHERE Country = 'USA')

Go ahead, try it. :)

Incidentally, for those of you wanting to learn lots more about cool SQL-92 stuff, get books from Joe Celko. He's the master at explaining this stuff.
-Chuck Urwiler, MCSD, MCDBA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform