Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cartesian problem
Message
 
 
To
01/04/2002 15:17:56
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00639646
Message ID:
00639737
Views:
17
There're a few ways to do that.
-- #1
SELECT * FROM jw2_studemo_suniq_ident 
  WHERE ident NOT IN (SELECT ident FROM catcboe_students)

-- #2 Correlated subquery
SELECT * FROM jw2_studemo_suniq_ident v1
  WHERE NOT Exists (SELECT * FROM catcboe_students cs
           WHERE cs.ident = v1.ident )

-- #3
SELECT v1.* FROM jw2_studemo_suniq_ident v1
  LEFT OUTER JOIN catcboe_students cs
           WHERE v1.ident = cs.ident  AND cs.ident IS NULL )
You should run some tests to find out which one is the fastest. My guess would be that it's #2.


>Hi Group
>
>I would like to find the records in the jw2_studemo_suniq_ident view, that do not have a matching ident in the catcboe_students table.
>There are 72 matching records so I should get back 384 records
>
>This
>SELECT * FROM jw2_studemo_suniq_ident
>Returns 456 records in zero seconds
>
>This
>SELECT * FROM catcboe_students
>Returns 1801 records in zero seconds
>
>
< snip >
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform