Kodewick
開始學 →
基礎←→0 / 70

奧斯陸或羅馬

#017基礎IN約 3 分鐘

寵物醫院要在奧斯陸和羅馬辦活動,想通知那裡的主人。從 owners 表裡選出 city 是 'Oslo' 或 'Rome' 的人,要 name 和 city 兩列。

用到的表
owners
  • idPK
  • name
  • city
  • phone
pets
  • idPK
  • name
  • kind
  • age
  • weight
  • owner_idFK

pets.owner_id → owners.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
-- 在這裡寫:用 WHERE city IN (…) 留下這兩個城市的
SELECT name, city
FROM owners;
Ctrl + Enter 也能執行
結果

寫好了先點「執行」看看結果,沒問題再點「提交」。