Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting records from two different tables in one query
Message
From
15/03/2010 11:27:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01454516
Message ID:
01454554
Views:
56
>>Hello!
>>I was just wondering if i can write a query that selects all the data not found in another table. like
>>select *
>>from table
>>where 100 is in one table... but not in the other table
>>?
>
>Try this syntax
>
>SELECT T1.* from myTable T1 LEFT JOIN myOtherTable T2 on T1.ID = T2.ID where T2.ID IS NULL
>
>This syntax is more robust than the other (in case you have NULLs in T2.ID) it would not select anything if using NOT IN syntax.
>
>In addition, it's more likely to be more performant.
>
>See also this link
>
>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/the-ten-most-asked-sql-server-questions--1#4

Ah you are right partially. Nulls are evils. A join would too erroneously select rows with null values on left:)

Performance wise I disagree join perfroms better. Last time I tested them I remember join was the slowest of all (this year).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform