|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello people...
I want to do the following query: SELECT * FROM tableA WHERE tableA.tableBKey NOT IN (SELECT tableBKey FROM tableB WHERE fieldB1='something'); but I need to do it with out the use of NOT IN for performance reasons. How can I do that? Maybe using joins... Thanks in advance...
__________________
-DdC |
|
#2
|
||||
|
||||
|
there are two ways:
Code:
select *
from tableA
where not exists
( select 1
from tableB
where tableBKey = tableA.tableBKey
and fieldB1 = 'something' )
Code:
select tableA.*
from tableA
left outer
join tableB
on tableA.tableBKey = tableB.tableBKey
and tableB.fieldB1 = 'something'
where tableB.tableBKey is null
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > SQL JOIN instead NOT IN |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|