Sail Soft SQL Report exception: Error in multi-table connection: column not explicitly defined

Source: Internet
Author: User
Tags one table

I just started the code:

1 Select2Dm_veh_jdcgz_mx. DAY_ID,--Date3Dm_veh_jdcgz_mx. GLBM,--Administrative Department ID4Dm_veh_jdcgz_mx. SFZMHM,--ID Number5Dm_veh_jdcgz_mx. DSRXM,--name6Dm_veh_jdcgz_mx. Gzts,--Notes7 8Dim_bas_gzzl. GZZL_MC,--name of management Department9 TenDIM_BAS_GLBM. GLBMMC,--name of management Department OneDIM_BAS_GLBM. DLBMMC,--Brigade name ADIM_BAS_GLBM. Xlbmmc--Contact Address -  from  - dm_veh_jdcgz_mx the  Left JoinDim_bas_gzzl -  on -Dim_bas_gzzl. Gzzl=dm_veh_jdcgz_mx. Gzzl -  Left JoinDIM_BAS_GLBM +  on -DIM_BAS_GLBM. Glbm=dm_veh_jdcgz_mx. GLBM + where 1=1${if(Len(GLBM)==0,""," andGlbminch('"+glbm+"')")} A  and atday_id>=Replace('${starttime}','-',"') -  and  -day_id<=Replace('${endtime}','-',"')

Baidu for a long time, finally find the reason.

original link:7432774

Original content:

In a query statement, an error often occurs:
SQL Foundation: ORA-00918: Error with column not explicitly defined.

There are two kinds of situations currently encountered. The reason is: when the query statement, the query table (dataset) has the same field name, the query field can not be confirmed that the field is changed
, errors that do not explicitly define the column are reported.

First case:
1. Single-table:
For example, there are three fields in a 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 will get an error because the FCSG_CONSIGN_ID has two fields in T, causing the DBMS to not 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 that will not be an error.

In summary: In a nested query, the field of the outer query can only appear in a subquery, otherwise it is not possible to determine which field to check. Errors that do not explicitly define the column are reported.

2. Multi-table Joint query
For example, there is a field in table A and B.
Select a from a A, this will be an error. Because it's impossible to determine

Which column. Need to explicitly define A.A alive B.A (if the table is aliased after the from statement, such as select S_no,s_name,s_score,s.class_no,class_name from student S join Class C on (S.C Lass_no = c.class_no), the same field name that is owned by more than one table in the SELECT statement also needs to be identified with an alias such as: S.class_no.)

Later I looked at my own sql,select when the name of the table has been clearly listed, looked for a long time, finally found the reason.

For example, in if, indicate which table the field belongs to.

Sail Soft SQL Report exception: Error in multi-table connection: column not explicitly defined

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.