截斷字串
在上一個練習中,你計算了 description 欄位的長度,發現字元數不一,但大多超過 75 個字元。實務上常需要把文字欄位截斷到特定長度,才能符合應用程式的需求。這個練習中,我們要擷取 description 欄位的前 50 個字元。
本練習屬於課程
在 PostgreSQL 操作資料的函式
練習說明
- 以別名
short_desc選取description欄位的前 50 個字元
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
SELECT
-- Select the first 50 characters of description
___(___, ___) AS ___
FROM
film AS f;