Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server Syntax to join 2 tables
Message
 
 
À
07/06/2005 09:30:15
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:
01020875
Message ID:
01020888
Vues:
15
>I used the syntax that you gave me but it returned 2 records instead of 1. Is there something that I am missing ? the following is the syntax I used
>"SELECT * FROM CIVIL JOIN persons ON persons.pkeyident = civil.keyident AND (persons.per_type = 'D' or persons.per_type = 'C')"

Assuming that you want only info from the main table (correct if I'm wrong)
SELECT DISTINCT civil.* 
  FROM CIVIL 
   JOIN persons ON persons.pkeyident = civil.keyident 
      AND persons.per_type IN ('D', 'C'))

-- or
SELECT * 
  FROM CIVIL 
   WHERE EXISTS (SELECT * FROM persons WHERE persons.pkeyident = civil.keyident 
      AND persons.per_type IN ('D', 'C'))
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform