sql数据库中    有两个记录 注册用户账号的 表当新注册用户时  怎么判断 不跟  这两个表中任何一个  已经注册的账号 重复?不知道我表达清楚了么请教高手帮忙了

解决方案 »

  1.   

    if exists(select 1 from TA where id=@id) or exists(select 1 from TB where id=@id) 
      

  2.   

    换个说法是不是好点啊。。就是先有两个表   表1和表2注册新用户时 先跟 表1 判断 是否id已经被注册再跟 表2  判断 是否id已经被注册 如果两个表中都没有信息 就成功注册。
      

  3.   


    if exists(select * from t1 where id=@id) and exists(select* from t2 where id=@id)
      print '可以注册'
    else
    begin
      print 'id已经被注册'
      rollback
    end
      

  4.   

    if not exists(select * from t1 where id=@id) and not exists(select* from t2 where id=@id)
      print '可以注册'
      

  5.   


    if exists(select 1 from TA where id=@id) or exists(select 1 from TB where id=@id)
      print 'id已经被注册'