LoginSignup
0
0

More than 3 years have passed since last update.

同型テーブルABのAにのみ存在するレコードを抽出

Posted at

その1

BがNULL(紐づかない列)を除外することでAにあるレコードのみ抽出

part1.sql
SELECT
    A.Name
FROM
    ATbl A Left Join
    BTbl B
ON A.CD = B.CD
WHERE
    B.CD Is NULL

その2

Existsを利用しレコードが返却されない行を抽出

part2.sql
SELECT
    A.Name
FROM
    ATbl A
WHERE
    Not Exists (
        SELECT 1 FROM BTbl B WHERE B.CD = A.CD)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0