Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert / Update
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01503367
Message ID:
01503374
Vues:
46
>Is there a way to “update” a table from another table appending or inserting only items that are not already in the target table with one function?
>Currently I create a cursor containing only those values not already in the target table, then scan it and do the insert function.
>
>This seems a little like brute force. Is there a more elegant way?
>
>I was looking at Update – SQL, but it seems it can only change existing field values.
>
>I was thinking something along these lines;
>
>Insert into A ;
>(F1, F2, F3) ;
>Where !F1 IN (select B.F1 from B)
>Values ;
>(B.F1, B.F2, B.F3)
>
>Thanks in advance
>
>Gary

Do you want to insert or update?

For insert
INSERT into TableA (F1, F2, F3)
select F1, F2, F3 from TableB
where not exists (select 1 from TableA where TableA.F1 = TableB.F1)
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform