比如某数据表的一行记录各字段名为ID A B C D E F G
按照ID做查询,查询结果显示为
A         A对应的值
B         B对应的值
C         C对应的值
D         D对应的值
E         E对应的值
F         F对应的值
G         G对应的值
 

解决方案 »

  1.   

    select a id1 from tab1 where id='' union all
    select b from tab1 where id='' union all
    select c from tab1 where id='' union all
    select d from tab1 where id='' union all
    select e from tab1 where id='' union all
    select f from tab1 where id='' union all
    select g from tab1 where id='' 
      

  2.   

    楼主可建一临时表
    CREATE GLOBAL TEMPORARY TABLE tmp (colname VARCHAR2(1), val INT);然后向其中插入数据(假设某数据表名为sometab,id值为someid)INSERT ALL
    INTO tmp VALUES('A',a)
    INTO tmp VALUES('B',b)
    INTO tmp VALUES('C',c)
    INTO tmp VALUES('D',d)
    INTO tmp VALUES('E',e)
    INTO tmp VALUES('F',f)
    INTO tmp VALUES('G',g)
    SELECT * FROM sometab
     WHERE id = someid;SELECT * FROM tmp;即可。