Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL select syntax
Message
De
14/10/2003 13:29:01
 
 
À
14/10/2003 13:00:53
Stephen Hunt
Admit Computer Services Inc.
Farmingdale, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00838601
Message ID:
00838620
Vues:
17
You probably don't want field1 from each table since they will all be the same, but probably certain fields from each table. Try
Select t1.field1, t2.field2, t3.field4 ;
     from table1 t1, table2 t2, table3 t3 ;
     where t1.field1 = t2.field1 and t1.field1 = t3.field1

*!* or if you don't mind single character aliases in SQL Selects, VFP help would suggest 

Select a.field1, b.field2, c.field4 ;
     from table1 a, table2 b, table3 c ;
     where a.field1 = b.field1 and a.field1 = b.field1
Anyway, you can reference each table in the "from" line with an alias and use that alias to reference which fields from which table you want to include in the result data set. If you actually want fields from each table that have duplicated fieldnames, you can use the "AS" key word after each field to rename the column to whatever you wish.
Select t1.field1 AS t1field1, t2.field1 AS t2field1, t3.field1 AS t3field1, ;
     t2.field2, t3.field4 ;
     from table1 t1, table2 t2, table3 t3 ;
     where t1.field1 = t2.field1 and t1.field1 = t3.field1
HTH


>I am trying to run an sql select statement while selecting all records
>from 3 different files, but I get an error "too many columns so I wanted to just select a couple different fields from each table instead of all records from each table my old syntax was "select * from table1,table2,table3 where table1.field1=table2.field1 and table1.field1=table3.field1" what is the syntax for just selecting field1 from table1,2, & 3 ?
>
>Thanks For Your Help
>Stephen J. Hunt
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform