Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you do an UPDATE like this?
Message
 
À
23/02/2000 10:50:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00336023
Message ID:
00337553
Vues:
16
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform