Problem Description:
Usually the English data entered in the database will have mixed case. The database is not aware of the case of keywords during fuzzy query. We need to process the data to search for the data correctly.
For example: Tom
search keywords stored in English and Chinese names in the database : Tom, T, To, can be retrieved correctly.
Search keywords: TOM, TO cannot be searched.
Solution: uniformly convert keywords to uppercase or lowercase, and the corresponding database fields should also be converted to uppercase or lowercase
SELECT *
FROM USER
WHERE UPPER( EN_NAME )
LIKE CONCAT( CONCAT( '%',UPPER(#{search})),'%')
SELECT *
FROM USER
WHERE
LOWER( EN_NAME )
LIKE CONCAT( CONCAT( '%',LOWER(#{search})),'%')
Convert keywords to uppercase and lowercase in java business
search=search.toUpperCase()
search=search.toLowerCase()
SQL in business
<select id="findPageCount" parameterType="com.ats.dt.entity.vo.MapperPage" resultType="int">
SELECT count(1) FROM BUSINESS_TERMS WHERE IS_DELETE = 0
<if test="search!=null">
<!--and ( CN_NAME like '%'+#{search}+'%' or EN_NAME like '%'+#{search}+'%' or EN_SHORT_NAME like '%'+#{search}+'%' )-->
and (CN_NAME like CONCAT(CONCAT('%',#{search}),'%') OR UPPER(EN_NAME) like CONCAT(CONCAT('%',#{search}),'%') OR
UPPER(EN_SHORT_NAME) like CONCAT(CONCAT('%',#{search}),'%') OR PY_CODE like CONCAT(CONCAT('%',#{search}),'%')
OR WB_CODE like CONCAT(CONCAT('%',#{search}),'%') OR BUSINESS_TERMS_SOID like CONCAT(CONCAT('%',#{search}),'%'))
</if>
</select>
<select id="findPage" parameterType="com.ats.dt.entity.vo.MapperPage" resultMap="BaseResultMapVo">
select * FROM
(SELECT A.*, ROWNUM RN FROM (SELECT BT.*,case BT.status when 150 then '未启用' when 149 then '启用' end as STATUS_NAME
FROM BUSINESS_TERMS BT WHERE 1=1 and IS_DELETE = 0
<if test="search!=null">
<!--and ( CN_NAME like '%'+#{search}+'%' or EN_NAME like '%'+#{search}+'%' or EN_SHORT_NAME like '%'+#{search}+'%' )-->
and (CN_NAME like CONCAT(CONCAT('%',#{search}),'%') OR UPPER(EN_NAME) like CONCAT(CONCAT('%',#{search}),'%') OR
UPPER(EN_SHORT_NAME) like CONCAT(CONCAT('%',#{search}),'%') OR PY_CODE like CONCAT(CONCAT('%',#{search}),'%')
OR WB_CODE like CONCAT(CONCAT('%',#{search}),'%') OR BUSINESS_TERMS_SOID like CONCAT(CONCAT('%',#{search}),'%'))
</if>
ORDER BY CREATE_DATE DESC) A
)
WHERE RN BETWEEN #{pageSt} AND #{pageEd}
</select>