一个表里有ID记录,另一个表里的tid是关联在第一表里面ID列上的,现想找出所有第二个表里没有关联到第一表ID的所有记录

解决方案 »

  1.   

    select * from table2 where tid not in (select id from talbe1)
      

  2.   

    select   *   from   table2   where   tid   not   in   (select   id   from   talbe1)
    这个有许多重复记录出来
      

  3.   

    这样出来的就是TID在ID中不存在的记录啦?重复的删掉就行啦
    你到底想要什么效果
      

  4.   

    加个DISTINCT可以去除重复的行
    select DISTINCT * from table2 where  tid not  in   (select id  from  talbe1)