RIGHT OUTER JOIN postgres=# \d shopa_shoes postgres=# \d shopb_shoes

postgres=# \d shopa_shoes
                                 Table "public.shopa_shoes"
 Column |       Type        | Collation | Nullable |                 Default                 
--------+-------------------+-----------+----------+-----------------------------------------
 id     | character varying |           | not null | nextval('shopa_shoes_id_seq'::regclass)
 size   | numeric           |           |          | 
postgres=# \d shopb_shoes
                 Table "public.shopb_shoes"
 Column |       Type        | Collation | Nullable | Default 
--------+-------------------+-----------+----------+---------
 id     | character varying |           |          | 
 size   | numeric           |           |          | 
postgres=# SELECT * FROM shopA_shoes;
  id  | size
------+------
 0001 | 23.5
 0001 | 24.5
 0003 |   24
(3 rows)
postgres=# SELECT * FROM shopB_shoes;
  id  | size
------+------
 0001 | 24.5
 0002 |   23
 0005 | 22.5
(3 rows)
postgres=# SELECT * FROM shopA_shoes RIGHT OUTER JOIN shopB_shoes ON shopA_shoes.id = shopB_shoes.id;
  id  | size |  id  | size
------+------+------+------
 0001 | 24.5 | 0001 | 24.5
 0001 | 23.5 | 0001 | 24.5
      |      | 0002 |   23
      |      | 0005 | 22.5
(4 rows)

いいなと思ったら応援しよう!