データは以下のようになっているとします。 mysql> select * from Samples.CUSTOMER; +----+-----------+---------+ | ID | NAME | USER_ID | +----+-----------+---------+ | 1 | CUSTOMER1 | 1 | | 2 | CUSTOMER2 | NULL | | 3 | CUSTOMER3 | 3 | | 4 | CUSTOMER4 | 2 | | 5 | CUSTOMER5 | 2 | +----+-----------+---------+ 5 rows in set (0.00 sec) mysql> select * from Samples.USER; +----+-------+ | ID | NAME | +----+-------+ | 1 | USER1