select * from (
select Table1.*,Table1.ID as IDD from Table1
left join Table2 on Table2.ID=Table1.ID) as a
where a.IDD is not null

解决方案 »

  1.   

    select * from table1
    where id not in(select 产品ID from table2)
      

  2.   

    select * from (
    select Table1.*,Table1.ID as IDD from Table1
    left join Table2 on Table2.ID=Table1.ID) as a
    where a.IDD is null
      

  3.   

    select a.*
    from table1 a
    where not exists(select 1 from table2 where id = a.id)
      

  4.   

    select * from Table1 where not exists (select 1 from Table2 where Table1.ID=Table2.ID)
      

  5.   


    --子查詢
    Select Distinct Table1.ID
    From Table1
    Where Table1.ID Not In (Select Distinct Table2.ID From Table2)
    --左聯接
    Select Distinct Table1.ID
    From Table1  Left Join Table2 On Table1.ID=Table2.ID
    Where Table2.ID Is NULL
      

  6.   


    select * from Table1 where id not in (select id from Table2)