select 1 a,2 a
/*
a           a
----------- -----------
1           2(1 行受影响)
*/
在查询列表可以多个列名相同,在一张物理表上列名必须唯一.

解决方案 »

  1.   

    if object_id('[tb]') is not null drop table [tb] 
     go 
    create table [tb](a varchar(10),b varchar(10),c int,d varchar(10))
    insert [tb] select 'a','b',3,'科室1'
    union all select 'a','c',3,'科室1'
    union all select 'c','a',2,'科室1'
    union all select 'c','b',1,'科室1'
    union all select 'b','a',1,'科室1'
    union all select 'b','c',1,'科室1'select tb1.d "中文",tb1.b "英文",tb1.d "中文" from tb tb1
    /*
    中文         英文         中文
    ---------- ---------- ----------
    科室1        b          科室1
    科室1        c          科室1
    科室1        a          科室1
    科室1        b          科室1
    科室1        a          科室1
    科室1        c          科室1(6 行受影响)
    */
      

  2.   

    if object_id('[tb]') is not null drop table [tb] 
     go 
    create table [tb](a varchar(10),b varchar(10),c int,d varchar(10),e varchar(10))
    insert [tb] select 'a','b',3,'科室1','科室2'
    union all select 'a','c',3,'科室1','科室2'
    union all select 'c','a',2,'科室1','科室2'
    union all select 'c','b',1,'科室1','科室2'
    union all select 'b','a',1,'科室1','科室2'
    union all select 'b','c',1,'科室1','科室2'select tb1.d "中文",tb1.b "英文",tb1.e "中文" from tb tb1
    /*
    中文         英文         中文
    ---------- ---------- ----------
    科室1        b          科室2
    科室1        c          科室2
    科室1        a          科室2
    科室1        b          科室2
    科室1        a          科室2
    科室1        c          科室2(6 行受影响)
    */这样看更明显一点
      

  3.   


    我猜楼主说的应该是这种select * from
    (
      select tb1.d "中文",tb1.b "英文",tb1.e "中文" from tb tb1
    ) t/**服务器: 消息 8156,级别 16,状态 1,行 1
    多次为 't' 指定了列 '中文'。**/