zoukankan      html  css  js  c++  java
  • 处理逗号分隔的字符串转为列表的list(行转列)解决跨库无法使用问题

    1.  这个方可以  但是会出现跨库无法使用问题

    select DISTINCT (substring_index(substring_index(a.id,',',b.help_topic_id+1),',',-1)) id
            from
            (SELECT CONCAT_WS(',',fill_recheck_user_job_no,fill_check_user_job_no,fill_user_job_no) id
            FROM 表名
            WHERE id = #{id}) a
            join mysql.help_topic b
            <![CDATA[
            on b.help_topic_id < (length(a.id) - length(replace(a.id,',',''))+1)
            ]]>
    

      

    2. 类似于   select * from tablename  where  id in (1,2,3)

    SELECT CONCAT_WS(',',fill_recheck_user_job_no,fill_check_user_job_no,fill_user_job_no) id

    FROM 表名
    WHERE id = #{id}    这个查出的数据是一个字符串的 "1,2,3"
    使用下面的写法可以转化
    find_in_set(对比参数, (SELECT CONCAT_WS(',',fill_recheck_user_job_no,fill_check_user_job_no,fill_user_job_no) id

    FROM 表名
    WHERE id = #{id})

    可以改为这个写法  

    select * from tablename  where  

    find_in_set(id , (SELECT CONCAT_WS(',',fill_recheck_user_job_no,fill_check_user_job_no,fill_user_job_no) id

    FROM 表名
    WHERE id = #{id})
  • 相关阅读:
    责任链模式(Chain of Responsibility)
    模板模式(Template Method)
    组合模式(Composite Pattern)
    原型模式(Prototype Pattern)
    策略模式(Strategy Pattern)
    状态模式(State Pattern)
    增删改查
    安卓sql
    安卓第三次作业
    安卓第四周作业
  • 原文地址:https://www.cnblogs.com/huanglp/p/14750448.html
Copyright © 2011-2022 走看看