Oracle does not explicitly define a column error ____oracle

Source: Internet
Author: User
Tags one table
Operating environment: oracle10g sqlplus Environment.
In a query statement, an error often occurs:
SQL Base: ORA-00918: An error that does not explicitly define a column.

There are two situations that are currently encountered. The reason is: when the query statement, the query's table (dataset) has the same field name, query field can not be confirmed to check that field
, an error that does not explicitly define the column is reported.

In the first case:
1. When one table:
For example, there are three fields in the Fconsign table: Fcsg_consign_id,fcsg_consign_type,fcsg_consign_status
Select fcsg_consign_id from (select fcsg_consign_id,fcsg_consign_type,fc.* from Fconsign FC) T
This SQL statement is an error, because there are two fields in T fcsg_consign_id, causing the DBMS to be unable to determine which column to query
Select Fcsg_consign_status from (select fcsg_consign_id,fcsg_consign_type,fc.* from Fconsign FC) T
This will not be an error, T fcsg_consign_status only one, so there will be no error.

All in all: in a nested query, a field in an outer query can only appear in a subquery, otherwise you cannot determine which field to look up. Errors that do not explicitly define the column are reported.

2. Multi-table Joint query
For example, there is a field in the table A,b.

Select a from a,b this will be an error. Because it's not sure which column to check. You need to explicitly define A.A or B.A (if you alias a table after the from statement, such as

When select S_no,s_name,s_score,s.class_no,class_name from student S joins Class C on (S.class_no = c.class_no), the SELECT statement The same field name that is owned by more than one table also needs to be identified with an alias such as: S.class_no.


Reproduced from: http://blog.csdn.net/wxdsdtc831/article/details/7432774

Related Article

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.