例如--
select * into tc 
from shopentinfo2
inner join workstudyinfo2
on shopentinfo2.familyid=workstudyinfo2.familyid and shopentinfo2.memberid=workstudyinfo2.memberid
where shopentinfo2.familyid like 'd%' and shopentinfo2.acttype=1 and shopentinfo2.经度>0
报错说有列名重复(即familyid memberid),因此无法写入tc。
怎么让它自动的不输出重复列?

解决方案 »

  1.   

    因为两个表有名字一样的字段,不要用select *
    把需要的字段都写上
      

  2.   

    两表join,如果不加条件限定的话,两表所有的字段都选出来(即使是重复的字段)这样的话,你在insert into tc的时候,就肯定会出现字段个数不匹配的情况了。
      

  3.   

    select tb1.col1,tb1.col2,tb2.col3
    from tb1 inner join tb2 on
      

  4.   


    select distinct * into tc 
    from shopentinfo2
    inner join workstudyinfo2
    on shopentinfo2.familyid=workstudyinfo2.familyid and shopentinfo2.memberid=workstudyinfo2.memberid
    where shopentinfo2.familyid like 'd%' and shopentinfo2.acttype=1 and shopentinfo2.经度>0
      

  5.   


    一个一个写上所有字段,有点麻烦,因为经常做各种join。
    没有更快的方法吗?