SELECT a.*, count(p.id) AS pnum FROM activity a left join activity_type aty on aty.id=a.type left JOIN player p ON p.reg_place = #{orgId} and ((p.current=1 and p.is_pay=0) or(p.current>1)) AND activity_id IN (a.id) WHERE LOCATE(#{orgId}, a.org_list) > 0 and a.state <>2 <if test="type!=-1"> and (a.type like concat('%',#{type},'%')) </if> GROUP BY a.id ORDER BY a.create_time DESC limit #{page},#{rows}
mysql中的LOCATE,返回param在目標字符串中第一次出現的位置,若是沒有則返回0;mysql