General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
What does it mean to be a 'correlated query'.
Brenda
>
>
* In table1
SELECT * FROM table2 ;
WHERE custn1+custn2 IN ( SELECT custn1+custn2 FROM table1)
* the same with correlated query (could be slower or faster than previous)
SELECT * FROM table2 t2 ;
WHERE EXISTS ( SELECT * FROM table1 t1 ;
WHERE t1.custn1+ t1.custn2 = t2.custn1+ t2.custn2)
* or if you've separate indexes on custn1 and custn2
SELECT * FROM table2 t2 ;
WHERE EXISTS ( SELECT * FROM table1 t1 ;
WHERE t1.custn1 = t2.custn1 And t1.custn2 = t2.custn2)
* Not in table1
SELECT * FROM table2 ;
WHERE custn1+custn2 NOT IN ( SELECT custn1+custn2 FROM table1)
* for correlated queries just change EXISTS to NOT EXISTS
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only