SQL Server - NOT IN

前端 未结 6 864
情书的邮戳
情书的邮戳 2020-12-29 19:50

I need to build a query that will show me records that are in Table 1, but that are not in Table 2, based on the make-model-serial number combination.

I know for fac

6条回答
  •  长情又很酷
    2020-12-29 20:48

    Use a LEFT JOIN checking the right side for nulls.

    SELECT a.Id
    FROM TableA a
    LEFT JOIN TableB on a.Id = b.Id
    WHERE b.Id IS NULL
    

    The above would match up TableA and TableB based on the Id column in each, and then give you the rows where the B side is empty.

提交回复
热议问题