У меня есть этот оператор SQL, где есть много предложений not exists
.Есть ли способ переписать условия и избежать сканирования одной и той же таблицы?
select col1,
col2,....,colN
from tab1
join <some join conditions> tab3
where not exists (select null
from tab2 p
where <some conditions eg: name = 'ABC'>
and tab1.some_col = tab2.some_col)
and not exists (select null
from tab2 p
where <some conditions eg: last_name = 'XYZ'>
and tab1.some_col = tab2.some_col)
and not exists (select null
from tab2 p
where <some conditions eg: country = 'PQR'>
and tab1.some_col = tab2.some_col)
and not exists (select null
from tab2 p
where <similar conditions>
and tab1.some_col = tab2.some_col)
and not exists (select null
from tab2 p
where <similar conditions>
and tab1.some_col = tab2.some_col);
В приведенном выше запросе больше не существует аналогичных способов.поскольку в предложении «не существует» есть одна и та же таблица для проверки, есть ли способ объединить их, не существует в один тип подзапроса.