有这样一张表:itemid   planid        a             b             c         d                    e             f121       365     1、工作方针    实现的方法   2、工作计划  计划如何实施     3、你喜欢什么书     如何去调研在页面上显示的效果为:1、工作方针   实现的方法2、工作计划   计划如何实施3、你喜欢什么书     如何去调研像这种形式该实现呢?

解决方案 »

  1.   

    你试下这样子行不,不过这样做效率就比较低了  
    select temp.*
       (select  itemid,planid,a c1,b c2
        from table
       union 
        select itemid,planid,c c1,d c2
        from table  
       union 
        select itemid,planid,e c1,f c2
        from table) temp
        group by itemid
      
      

  2.   

    呵呵,这不是SQL 行列倒置的问题吗SQL板块,那些牛人,早就有现成的代码了,去看下吧。
      

  3.   

      写错了 应该是  order by  itemid
      

  4.   


    SQL codeselecttemp.*
       (select  itemid,planid,a c1,b c2fromtableunionselect itemid,planid,c c1,d c2fromtableunionselect itemid,planid,e c1,f c2fromtable)temp order by itemid