先上代码:
insert into messtu(type,telno,telno) select '1',firstphonecode,secondphonecode from student服务器: 消息 264,级别 16,状态 1,行 1
在结果列的列表中多次出现列名 'telno'。这样是错误的.我真想把两个字段同时写到telno.可这样不行.有没有好的方法?

解决方案 »

  1.   

    insert into messtu(type,telno) 
    select '1',firstphonecode from student
    union all
    select '1',secondphonecode from student
      

  2.   

    强烈感谢 wufeng4552,实现了!
      

  3.   

    如果在以上查询中加入子查询:
    insert into messtu(type,telno) 
    select '1',firstphonecode from student where firstphonecode = ‘’
    union all
    select '1',secondphonecode from student where firstphonecode = ‘’
    有没有办法只输入一个子查询,不要两个语句都用子查询?