Kodewick
开始学 →
小挑战←→0 / 70

还没有宠物

#063小挑战子查询NULL约 6 分钟

宠物医院的 owners 表里,有的人还没有宠物登记。选出这些人的 name:他们的 id 不在 pets 的 owner_id 里。注意 owner_id 有空的。

用到的表
owners
idnamecityphone
1LenaOslo555-0101
2MarcoRomeNULL
3PriyaOslo555-0103
4OmarCairoNULL
5SofiaRome555-0105
5 行
pets
idnamekindageweightowner_id
1Biscuitdog3121
2Mochicat541
3Pepperdog8202
4Nemofish1NULL3
5Lunacat233
6Rexdog1130NULL
7Kiwibird4NULL5
8Tofucat75NULL
8 行
query.sql
SELECT name
FROM owners
WHERE id NOT IN (
  -- 在这里写:pets 里的 owner_id,用 WHERE 去掉空的
);
Ctrl + Enter 也能运行
结果

写好了先点「运行」看看结果,没问题再点「提交」。