<select id="selectPhoneByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
phone
from t_person_info
where ID = #{id,jdbcType=VARCHAR}
</select>
select p.id, p.id as pid,p.name,p.idcard,p.phone,count( w.EVENT_NO ) AS count
from t_person_info p
left join t_other w on w.pid = p.ID
where
<foreach collection="phones" item="phone" separator="or" open="(" close=")">
p.phone like concat("%",#{phone},"%")
</foreach>
and p.id != #{id}groupby p.id
+select * from t_user where match(phone) AGAINST('a +b' in boolean mode)
其间 + 会被识别成逻辑运算符,而不是将a +b作为一个全体,以下同理。
‘a +b’ 指’a’和’b’有必要同时呈现才满意查找条件。
-select * from t_user where match(phone) AGAINST('0797 -12345' in boolean mode) 0797 -12345指0797有必要包括,但不包括12345才干满意查找条件。
以下查询排除了包括0797-12345的记载。
留意-前后空格 0797 -12345才表明包括0797 同时不包括12345.
0797-12345等于0797 - 12345,它并不等于0797 -12345。
有图为证:
><
提高/降低该条匹配数据的权重值。不管运用>仍是 <,其权重值均大于没运用其间任何一个的。 select * from t_user where match(phone) AGAINST('0797(>94649 <12345)' in boolean mode)
表明匹配0797,同时包括94649的列往前排,包括12345的往后排
select * from t_user where match(phone) AGAINST('a > b' in NATURAL LANGUAGE mode)
()
相当于表达式分组,参考上一个比如。
*
通配符,只能在字符串后面运用
"
完全匹配,被双引号包起来的单词有必要整个被匹配。
select * from t_user where match(phone) AGAINST('"0797-1789"' in boolean mode)"0797-1789"中不可再分。其它包括0797-1234等记载就不再匹配。
select p.id ,p.name,p.idcard,p.phone
from t_person_info p
innerjoin (select id from t_person_info orderby EVENTCOUNT desc limit 700000,15) p2 on p.id = p2.id
如此相同只需求200毫秒左右。
其它办法
其它办法,经过记载前次的方位,经过子查询,都只适用于id为自增主键的情况。
不适用我的这个事务场景。
类似于 这样的SQL
select id ,name,idcard,phone,EVENTCOUNT from t_person_info where id <=(select id from t_person_info order by EVENTCOUNT limit 700000, 1) limit 15;