Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with the second DB
Message
De
30/01/2022 01:53:43
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01683370
Message ID:
01683391
Vues:
57
>Hi,
>
>I am working on modifying a SQL Select that pulls data from two databases.
>The first one is the default.
>The second database is specified in the variable cSecondDb. For example,
>
>cSecondDb = "SQLDbNo2"
>
>
>In the SQL select I put the variable cSecondDb as a prefix to the table that is in the second DB. Example:
>Table 1 is in the 1st DB
>Table 2 is in the 2nd DB
>
>select column1 from Table1 where column2 in (select Table2.pk_field from " + cSecondDb + "Table2" +  where 
>Table2.field3 = 'xyz'
>
>I know that the above is probably not well formed SQL Select. But my question is,
>Do I need to put the variable cSecondDb before EACH and every time the table in the second DB is used? Or just in the FROM clause?
>That is, do I need the cSecondDb before "select table2.pk_field" or by saying that I am selecting FROM cSecondDb + "table2" is enough?
>TIA

IIRC, try this:
select column1 from Table1 where column2 in (select T2.pk_field from " + cSecondDb + ".Table2 as t2 where 
t2.field3 = 'xyz'

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform