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

寵物小標籤

#054基礎CONCAT約 3 分鐘

寵物醫院的籠子上要貼小標籤,寫成 Mochi (cat) 這樣:名字、一個空格、括號裡是種類。從 pets 裡給每隻寵物拼出這樣一列。

用到的表
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
-- 在這裡寫:用 CONCAT 把 name、' ('、kind、')' 拼起來
SELECT name, kind
FROM pets;
Ctrl + Enter 也能執行
結果

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