使用concat做多条件模糊查询
1. 字符串拼接
// java代码
searchText = "%" + searchText + "%";
// sql
SELECT
order_code,
send_linkman,
settled_amount
FROM
order_info
WHERE
account_code = #{accountCode}
AND
state = 1
AND CONCAT(order_code,received_linkman)
LIKE #{searchText }
ORDER BY
pay_time
DESC
2. 使用concat
// sql
SELECT
order_code,
send_linkman,
settled_amount
FROM
order_info
WHERE
account_code = #{accountCode}
AND
state = 1
AND CONCAT(order_code,received_linkman)
LIKE concat('%', #{searchText},'%')
ORDER BY
pay_time
DESC
3. bin标签
SELECT
order_code,
send_linkman,
settled_amount
FROM
order_info
WHERE
account_code = #{accountCode}
AND
state = 1
AND CONCAT(order_code,received_linkman)
LIKE #{searchText}
ORDER BY
pay_time
DESC