How can I implement SQL INTERSECT and MINUS operations in MS Access

前端 未结 5 539
梦谈多话
梦谈多话 2020-12-01 12:20

I have researched and haven\'t found a way to run INTERSECT and MINUS operations in MS Access. Does any way exist

5条回答
  •  星月不相逢
    2020-12-01 13:04

    INTERSECT is an inner join. MINUS is an outer join, where you choose only the records that don't exist in the other table.


    INTERSECT

    select distinct
      a.*
    from
      a
      inner join b on a.id = b.id
    

    MINUS

    select distinct
      a.*
    from
      a
      left outer join b on a.id = b.id
    where
      b.id is null
    

    If you edit your original question and post some sample data then an example can be given.

    EDIT: Forgot to add in the distinct to the queries.

提交回复
热议问题