Saturday, 7 January 2017

CORRELATED SUB QUERY



CORRELATED SUB QUERY:
=====================
1.if we have realtime requirement than only should  use the correlated subquery otherwise
not use why because it will decrease the query level performance
and data level performance.

                        CORRELATED SUB QUERY
                                   |
                                   |
            OUTER----------------SUBQUERY


2.the subquery which is depending on outer query result  is called a correlated subquery.
3.Generally the correlated sub query usefull/fetch reverse buisness process information.
    Means suppose SAMSUNG company  manufacturing some mobiles ,after one year if we want to see information about the products that  is there any mobile model which is not sold to atleast one customer?.
4.In correlated subquery between outer query and sub query we use two operators those are EXISTS, NOT EXISTS.
5. what is EXISTS?
    EXISTS operator always observing in subquery o/p that is if atleast one o/p value is generated  than EXISTS operator returns TRUE. If EXISTS operator returns TRUE  than outer query will execute result,if EXISTS operator returns FALSE than outer query will not execute result.

6.          INNER PROCESSING OF THE  CORRELATED SUBQUERY

                     
                                      CORRELATED SUBQUERY


 



                          1                              O/P
Oval: SUB
QUERY
Oval: OUTER QUERY            
                                                                                              



                                                            
                           3                                      O/P                                            2


Ø  The  sub suery which is depending on outer query that is the reason outer query will execute first once execute the outer query(1) it is generate some  o/p later that o/p will passed to the subquery based on that o/p the subquery executed one time(2) it will generate o/p and passed to the outer query here again executed outer query(3) based on the sub query o/p finally answer will executed.
Ø  According to the above process outer query executing  two times.that is the reason until requirement we do not create the correlated sub queries.

No comments:

Post a Comment