oracle 模糊查询语句 , 工作中用到的sql

	<select id="findAll" resultMap="BaseMeterMap">
	select * from (select rownum rownum_rn, a.* from(select
		am.meterId,
		am.meterBoxId,
		am.meter_name,
		am.meter_no,
		am.house_id,
		am.phase_remark,
		am.C_DistrictBCDId,
		am.C_AddressId,
		am.C_ChannelId,
		am.CREATE_TIME,
		am.CREATE_ID,
		am.UPDATE_TIME,
		am.UPDATE_ID,
		am.DEL_FLAG,
		am.leak_channel_id,
		court.PROVINCE_ID as epuProvince,
		pro.PROVINCE_NAME_CN as epuProvinceName,
		court.CITY_ID as epuCity,
		c1.CITY_NAME_CN as epuCityName,
		court.DISTRICT_ID as epuDistrict,
		c2.CITY_NAME_CN as epuDistrictName,
		am.epu_court as epuCourt,
		court.COURT_NAME_CN as epuCourtName,
		mb.EPU_NAME as meterBoxName
	from
		t_meter am
		left join T_METERBOX mb on am.METERBOXID= mb.METERBOXID
		left join t_sy_court_info court on am.epu_court=court.COURT_ID 
		left join T_SY_PROVINCES_INFO pro on court.PROVINCE_ID = pro.PROVINCE_ID 
		left join T_SY_CITY_INFO c1 on court.CITY_ID = c1.CITY_CODE 
		left join T_SY_CITY_INFO c2 on court.DISTRICT_ID = c2.CITY_CODE
	where 1=1 and
		am.DEL_FLAG='0' and mb.DEL_FLAG='0'
		<if test="epuProvince != '' and epuProvince != null">
			and court.PROVINCE_ID = #{epuProvince,jdbcType=VARCHAR}
		</if>
		<if test="epuCity != '' and epuCity != null">
			and court.CITY_ID= #{epuCity,jdbcType=VARCHAR}
		</if>
		<if test="epuDistrict != '' and epuDistrict != null">
			and court.DISTRICT_ID= #{epuDistrict,jdbcType=VARCHAR}
		</if>
		<if test="meterNo != '' and meterNo != null">
			and LOWER(am.meter_no) like LOWER('%'||#{meterNo,jdbcType=VARCHAR}||'%')
		</if>
		<if test="meterName != '' and meterName != null">
			and LOWER(am.meter_name) like LOWER('%'||#{meterName,jdbcType=VARCHAR}||'%')
		</if>
		<if test="houseId != '' and houseId != null">
			and LOWER(am.house_id) like LOWER('%'||#{houseId,jdbcType=VARCHAR}||'%')
		</if>
		<if test="districtId != '' and districtId != null">
			and LOWER(am.C_DistrictBCDId) like LOWER('%'||#{districtId,jdbcType=VARCHAR}||'%')
		</if>
		<if test="epuCourt != '' and epuCourt != null">
			and LOWER(am.EPU_COURT) like LOWER('%'||#{epuCourt,jdbcType=VARCHAR}||'%')
		</if>
		<if test="addressId != '' and addressId != null">
			and LOWER(am.C_AddressId) like LOWER('%'||#{addressId,jdbcType=VARCHAR}||'%')
		</if>
		<if test="findContent != null and findContent !='' ">
			and (
			LOWER(am.C_DistrictBCDId) like LOWER('%'||#{findContent,jdbcType=VARCHAR}||'%')
			or LOWER(am.C_AddressId) like LOWER('%'||#{findContent,jdbcType=VARCHAR}||'%')
			or LOWER(am.C_ChannelId) like LOWER('%'||#{findContent,jdbcType=VARCHAR}||'%')
			)
		</if>
			order by am.UPDATE_TIME desc
		) a)
		<include refid="limit_sql" />
	</select>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宁漂打工仔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值