如题,sql server 2000delete from #ta where exists (select 1 from #tb b where #ta.id=b.id) 上面是可以的,但是如果用了#ta的别名,就不行了,提示 : 'a'附近有语法错误 delete from #ta a where exists (select 1 from #tb b where a.id=b.id) 

解决方案 »

  1.   

    delete a
    from #ta a 
    where exists (select 1 from #tb b where a.id=b.id) 
      

  2.   

    delete #ta from #ta a where exists (select 1 from #tb  where id=a.id) 
      

  3.   

    终于明白为什么了,原来DEL语句真正删除的是delete语句后的那张表不信建张#tc表打上delete #tc from 后的语句随便打只要符合语法规则出不出现#tc无所谓看看究竟被删除的是那张表
      

  4.   

    delete a--用别名 from #ta a where exists (select 1 from #tb b where a.id=b.id) 
    delete #ta --用别名 from #ta a where exists (select 1 from #tb b where a.id=b.id) -------以上两种都可以
    delete  from #ta a--有别名时,等同于两个表.要指定一个表名
      

  5.   

    delete a
    from #ta a 
    where exists (select 1 from #tb b where a.id=b.id)