今天看到sql语句懵了,select aaa.* … 一直在找别名为aaa的表,结果只在最后括号外看到了aaa,然后搜索关于oracle的别名问题,没怎么找到,忽然想起来是嵌套查询,可能是子查询的别名?之前没用过。。。先记录一下,再慢慢研究。
部分代码:
select **aaa** .id_card,aaa.identify_date,bb.bio_type from(
SELECT P .id_card,MAX(P .identify_date) as identify_date
FROM app_task_person AT , unify_identify P
where P .id_card = AT .id_card
and ('1'!='1'
<if test="isVein == '1'.toString()">
or p.bio_type='1'
</if>
<if test="isFace == '1'.toString()">
or(p.bio_type='2' and p.identify_method <> '1')
or(p.bio_type='2' and p.identify_method <> '2')
or(p.bio_type='2' and p.identify_method <> '3')
or(p.bio_type='2' and p.identify_method <> '4')
</if>
<if test="isFinger == '1'.toString()">
or p.bio_type='3'
</if>
<if test="isManual == '1'.toString()">
or p.bio_type='4'
</if>
)
<if test="bioType != null and bioType != ''">
AND p.bio_type = #{bioType}
</if>
<if test="beginDate != null and beginDate != ''">
AND (p.identify_date BETWEEN
TO_DATE(#{beginDateStr},'yyyy-mm-dd hh24:mi:ss')
AND TO_DATE(#{endDateStr},'yyyy-mm-dd hh24:mi:ss') )
</if>
<if test="taskId != null and taskId != ''">
AND ( at.task_ids LIKE
<if test="dbName == 'oracle'">'%,'||#{taskId}||',%'</if>
<if test="dbName == 'postgre'">'%,'||#{taskId}||',%'</if>
<if test="dbName == 'mssql'">'%,'+#{taskId}+',%'</if>
<if test="dbName == 'mysql'">concat('%,',#{taskId},',%')</if>
OR at.task_id = #{taskId} )
</if>
GROUP BY p.ID_CARD
)**aaa**