Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server Syntax to join 2 tables
Message
 
 
To
07/06/2005 09:30:15
Stephen Hunt
Admit Computer Services Inc.
Farmingdale, New York, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01020875
Message ID:
01020888
Views:
16
>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform