i have a query like below

Select cltnme from clt00 where not exists( select 1 from cln00);

Here, cltnme is client name..
my confusion is what 'not exists( select 1 from cln00)' will do?

Please tell if you have any answers...


Views: 47

Replies to This Discussion

Hello Vijay!

The 'SELECT 1 FROM cln00' (1) query is almost equivalent to 'SELECT * FROM cln00' (2). The main difference is that when you use (2), the '*' will be expanded and attached to the list of columns, as for the (1) it will simply avoid to bind useless data to the main SELECT query. This is a normal procedure because the (NOT) EXISTS condition tests do not need any columns to return the boolean result. Thus (1) is faster than (2).

Maybe you will understand the query like that, which is equivalent to yours:

SELECT cltnme
FROM clt00
WHERE ctlnme IN (
SELECT ctlnme FROM clt00
SELECT ctlnme FROM cln00 )

Actually you are selecting all the cltnme from clt00 that aren't in cln00.

I hoped I could help.



Featured Downloads

Try BLU Acceleration on Cloud

© 2020   Created by channeldb2.   Powered by

Badges  |  Report an Issue  |  Terms of Service