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>
相關文章
相關標籤/搜索