Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Where clause with extended conditions

AB SamyDec 17 2018 — edited Dec 17 2018

Hi Experts, I need some clarifications  on “WHERE” clause extended conditions. Let’s say I have a where clause  with couple of scenarios like below

1.Where customer Id=’pk’ and store_number =’001’      And          Oder_Id=’ 221’ and Product_ID=’333’                Company_name =X OR Company_name=Y

2. where (customer Id=’pk’ and store_number =’001’    And          Oder_Id=’ 221’ and Product_ID=’333’                Company_name =X OR Company_name=Y)

3. where (customer Id=’pk’ and store_number =’001’      And          Oder_Id=’ 221’ and Product_ID=’333’              ( Company_name =X OR Company_name=Y))

4. where(customer Id=’pk’ and store_number =’001’        And        (Oder_Id=’ 221’ and Product_ID=’333’)              ( Company_name =X OR Company_name=Y))

I understand in 1 st scenario 'And' condition will execute first as it has high priority than OR  , would it be the same case in 2nd scenario which just has parenthesis.  My understanding is 3rd scenario OR will be executed first as I have prioritized it.In 4rth scenario And will be executed first then OR  and lastly the and. Please correct me if I am wrong. Thanks.

This post has been answered by Cookiemonster76 on Dec 17 2018
Jump to Answer
Comments
Post Details
Added on Dec 17 2018
17 comments
2,500 views