是要弄临时表吗?直接用SQL语句可以搞定吗?

解决方案 »

  1.   

    不能直接用SQL语句,要用辅助表
      

  2.   

    列转行。
    group_concat()函数处理
    也可以用case when去操作。
      

  3.   

    select id,group_concat(ids)
    from tb
    group b id
      

  4.   

    select ids from tb where ids=12
    union 
    select ids from tb where ids=13
    union
    select ids from tb where ids=14
    union 
    select ids from tb where ids=15
    union 
    select ids from tb where ids=16
    union 
    select ids from tb where ids=17