The subquery contains nonexistent columns--not bug!.

Source: Internet
Author: User

1. Phenomena

CREATE Table A as (select 1 as col_a), create table B as (select 2 as Col_b) SELECT * from a Where col_a in (select Col_a fro M b)

Where Col_a exists only in table_a, Table_b does not have the field, and the result of the entire statement can be executed successfully!


2. Reason:

The problem is confusing, and the reason for this is that "automatically looks for the outer layer when the column name in the subquery does not exist."

In other words, the above query is actually interpreted as a

SELECT * from a where col_a in (col_a)

The equivalent of the constraint that automatically shields the subquery.

3. Modification:

To prevent this from happening, you need to ensure that SQL in the subquery runs correctly, and then view the SQL as a whole

The subquery contains nonexistent columns--not bug!.

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.