Oracle layer-3 nested query bug

Source: Internet
Author: User

The following SQL statement does not query any records, even though the database has qualified records. This is an Oracle layer-3 query bug.

Select cb. * from mw_app.t_cb cb where cb. obj_id in

(Select CBA. channel_id from mw_app.t_current_business_alarm CBA where CBA. business_id in

(Select B. business_id from mw_app.t_rt_business B where B. alarm_state <> '0' and B. business_code = '1 '))

To query the results, you must change the SQL statement

Select cb. * from mw_app.t_cb cb Left Join (select alarm. channel_id from mw_app.t_current_business_alarm alarm

Where alarm. business_id in (select business_id from mw_app.t_rt_business where alarm_state <> '0' and business_code = '1') B

On cb. obj_id = B. channel_id

Or

Select cb. * from mw_app.t_cb cb Left Join (

Select alarm. channel_id from mw_app.t_current_business_alarm alarm left join mw_app.t_rt_business biz

On alarm. business_id = biz. business_id

Where (biz. alarm_state <> '0' and biz. business_code = '1') B

On cb. obj_id = B. channel_id

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.