1. 程式人生 > >mysql把表中某一欄位拆分為多列

mysql把表中某一欄位拆分為多列

一:sql資料庫截圖


二:sql語句

     SELECT id, house_no as '總稱',
SUBSTR(house_no, 1, 4) AS '小區名稱',
SUBSTR(house_no, -10, 3) AS '樓幢',
        SUBSTR(house_no, 5, 3) AS '樓幢2',
SUBSTR(house_no, -7,3) AS '單元',
SUBSTRING(house_no,-4) AS '房間號'
        FROMaa;

三:查詢結果圖