sql函数实现模糊精确匹配
例如:
查询的时候匹配[‘1’]
就只匹配1的 ,而不是15的也会模糊查询进去
slq函数如下:
CREATE
OR REPLACE FUNCTION does_string_array_intersect ( target_string TEXT, input_strings TEXT [] ) RETURNS BOOLEAN AS $$ BEGIN
RETURN string_to_array( target_string, ',' ) && input_strings;
END;
$$ LANGUAGE plpgsql;
sql查询语句:
SELECT* FROM ads_share_plot asplot WHERE does_string_array_intersect(hylb2, ARRAY['1'])
在java的xml中使用:
select *
from ads_share_plot asplot
WHERE 1 = 1
<if test="params.hylbs != null and params.hylbs.size() > 0">
and does_string_array_intersect(hylb2, ARRAY[
<foreach item="hylb" collection="params.hylbs" open=" " separator="," close=" ">
#{hylb}
</foreach>
])
</if>