2015-08-04 14:42



i have two tables. First table column value is 1,2,7. Second table column value is 1,2,3,4,5,6,7,8,9,10.

what i needed is i want to fetch second table values except first table values.Result should be 3,4,5,6,8,9,10.I do no what is the query for this one.Please help me.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongxingchang9345 dongxingchang9345 6年前
    SELECT value FROM secondtable WHERE value NOT IN (SELECT value FROM firsttable)
    点赞 评论 复制链接分享
  • douzhang7184 douzhang7184 6年前

    The standard SQL is to use NOT IN or NOT EXISTS:

    select t2.*
    from t2
    where not exists (select 1 from table1 t1 where t1.value = t2.value);
    点赞 评论 复制链接分享