list查询list

 参考:https://stackoverflow.com/questions/8352115/mysql-list-in-listmysql

 

1,使用IN方法sql

注:有bug(条件:01,02,03; 数据库:01,02能够匹配, 可是02,03没法匹配)数据库

SELECT * from tb_sys_article_shop where MODULAR in (01,03)

 

 

2,使用find_in_setspa

WHERE find_in_set(optionNumber1, choices) > 0 
OR find_in_set(optionNumber2, choices) > 0
OR find_in_set(optionNumber3, choices) > 0

 

select * from tb_sys_article_shop WHERE DELETE_TAG = 0 AND ( find_in_set("02", MODULAR) > 0 OR find_in_set("03", MODULAR) > 0 OR find_in_set("04", MODULAR) > 0 )

 

    <if test="modulars != null and modulars.size() > 0">
        AND
      <foreach item="item" index="index" collection="modulars" open="(" separator="OR" close=")">
          find_in_set(#{item}, MODULAR) > 0
      </foreach>
    </if>
相关文章
相关标签/搜索