June 20, 2005 at 2:42 am
Table 1 | Table 2 | |||
| Id | Name | Id | Name | |
| 1 | One | 1 | One | |
| 2 | Two | 2 | Two | |
| 3 | Three | 3 | Three | |
| 4 | Four | 4 | Four | |
| 5 | Five | 5 | Five | |
| 6 | Six | 6 | Six | |
| 7 | Seven | |||
| 8 | Eight | |||
| 9 | Nine | |||
| 10 | Ten | |||
| Reqiured | : | |||
| 7 | Seven | |||
| 8 | Eight | |||
| 9 | Nine | |||
| 10 | Ten |
Can anyone solve it without using JOIN or IF join used then result should be faster enough so that the performance is not an issue. Thanks.
/**A strong positive mental attitude will create more miracles than any wonder drug**/
June 20, 2005 at 3:06 am
Have a look at NOT EXISTS in BOL. ![]()
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 20, 2005 at 3:09 am
You need to use a join to get the best performance. Indexing on the id fields would also help a lot.
select * from table2 t2
left join table1 t1 on t2.id = t1.id
where t1.id is null
Regards
June 20, 2005 at 6:06 am
Frank,
Not Exists worked fine.
Many Thanks, for your suggestion.
/**A strong positive mental attitude will create more miracles than any wonder drug**/
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply