An alias for the SQL field, often thought to be optional, but sometimes necessary.
For example, in Ibatis
1 <!--get a list of sent or pending MMS Records--2 <Resultmap ID="Mmslistbyrecordtypemap" class="Richinfo.mms.bean.req.MmsRecordReq">3 <Resultcolumn="GroupID" Property="GroupId"/>4 <Resultcolumn="Subject" Property="Title"/>5 <Resultcolumn="Sendnumber" Property="Usernumber"/>6 <Resultcolumn="Destnumbers" Property="Destnumber"/>7 <Resultcolumn="Istime" Property="Istimming" Typehandler="Richinfo.mms.util.MyBatisTypeHandlerCallback"/>8 <Resultcolumn="Statuss" Property="Status"/>9 <Resultcolumn="Startsendtime" Property="Sendtime"/>Ten <Resultcolumn="TotalSize" Property="TotalSize"/> One </Resultmap> A <SelectId="Getmmslistbyrecordtype" Resultmap="Mmslistbyrecordtypemap" -ResultClass="Map"> - Select * from(SelectB.*, RowNum R from(Select theUin,fn_getdecryptusernumber (Sendnumber) Sendnumber,subject,to_char (Startsendtime,'YYYY-MM-DD Hh24:mi:ss') - Startsendtime,istime,showfileid,totalsize,showtype,groupid, - Wmsys.wm_concat (Fn_getdecryptusernumber (Destnumber)) Destnumbers,wmsys.wm_concat (NVL (Status, - 0)) Statuss fromMms_send_his_recordwhere 1=1 + <IsEqual prepend=" andThe property="RecordType" CompareValue="0"> -Issave=1 + </IsEqual> A <IsEqual prepend=" andThe property="RecordType" CompareValue="1"> at <![cdata[ - (istime=0 or (istime=1 and startsendtime<=sysdate)) and issave=1 - ]]> - </IsEqual> - <IsEqual prepend=" andThe property="RecordType" CompareValue="2"> - <![cdata[ in istime=1 and Startsendtime>sysdate - ]]> to </IsEqual> + andUIn=#uin # - <Include refID="Condition"/> the <![cdata[ * GROUP by Groupid,uin,fn_getdecryptusernumber (Sendnumber), subject,startsendtime,istime,showfileid,totalsize,s Howtype ORDER BY startsendtime Desc) b $ where RowNum <= #endRecord #Panax Notoginseng ]]> - <Isnotempty Property="Destnumber"> the <![cdata[ + and InStr (Destnumbers, #destNumber #) >0 or InStr (Destnumbers,fn_encrypt_function (#destNumber #)) >0 A ]]> the </Isnotempty> +)whereR>#startRecord # - </Select>
1, must be the 15th, 17 line Alias
If you do not alias lines 15th and 17, the execution of the SQL statement will be problematic. Because the query result set for this select is mapped on the Mmslistbyrecordtypemap, this time
If you do not alias, Fn_getdecryptusernumber (Sendnumber) and sendnumber are not equal, and the result cannot be mapped on usernumber.
Therefore, the names of the column names and Resultmap of the select query must be equal.
2. The GROUP BY statement does not require an alias
Oracle SQL aliases