Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Help
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00638949
Message ID:
00639011
Views:
23
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
Map
View

Click here to load this message in the networking platform