exists and not exists
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


exists and not exists Expand / Collapse
Author
Message
Posted 8/31/2008 2:28:04 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/11/2008 9:08:54 AM
Posts: 19, Visits: 130
there is a query
sel * from a where not exists(sel 1 from b join a on a.a1=b.b1);

as far as i know
With a correlated subquery, for EACH row in the main query a search of the subquery is made to find
a matching matching row, then a T/F value is returned.

but sel 1 will return only sinlgle col with all rows as 1
so i am confused how exactly EACH row in the main query is made to find
a matching matching row.

Also please tell me when it is suitable to use EXISTS/NOT EXISTS in place of OUTER JOINS?
Post #12792
Posted 9/17/2008 6:19:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/6/2008 1:53:32 AM
Posts: 6, Visits: 22
Hi,

If i am right..NOT EXISTS works like this...

The subquery is executed first...in your case..1 will be returned from the subquery if at all there exists a row that satisfies the condition..none of the rows are returned as the final resultset.If there is no row satisfying the condition..the NOT EXISTS condition becomes sucessful..All the rows from the table a are retrieved as the final result set..The processing is not done for each row...

Hope this helps...

Thanks,
Arun
Post #12926
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 4:43pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.047. 11 queries. Compression Disabled.