SQL Server - NOT IN

前端 未结 6 847
情书的邮戳
情书的邮戳 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:33

    You're probably better off comparing the fields individually, rather than concatenating the strings.

    SELECT t1.*
        FROM Table1 t1
            LEFT JOIN Table2 t2
                ON t1.MAKE = t2.MAKE
                    AND t1.MODEL = t2.MODEL
                    AND t1.[serial number] = t2.[serial number]
        WHERE t2.MAKE IS NULL
    

提交回复
热议问题