iT邦幫忙

2025 iThome 鐵人賽

DAY 10
0
Modern Web

Laravel 是甚麼系列 第 10

資料庫的datatype

  • 分享至 

  • xImage
  •  

coscup還是回味無窮阿~
/images/emoticon/emoticon06.gif


https://ithelp.ithome.com.tw/upload/images/20250813/20119035NU6avrJOrP.png

INT旁邊有數字,表示可以容納多少個數字
VARCHAR存文字,旁邊的數字45超過會存不進去
TINYINT存0跟1
調排序
https://ithelp.ithome.com.tw/upload/images/20250813/201190354U8mRRJhbO.png
往上拉按APPLY顯示就會不同
用語法看只要看的內容
目前可以看到全部用*
https://ithelp.ithome.com.tw/upload/images/20250813/20119035UwzlTcHafD.png
只要看到id跟win
SELECT id,win FROM sampledatabase.sbl_team_data;
https://ithelp.ithome.com.tw/upload/images/20250813/201190358W09LoW8Tp.png
撈出team_id=2
SELECT * FROM sampledatabase.sbl_team_data where team_id=2
https://ithelp.ithome.com.tw/upload/images/20250813/20119035YofwoefgAg.png
撈出team_id>2的資料
SELECT * FROM sampledatabase.sbl_team_data where team_id>2
https://ithelp.ithome.com.tw/upload/images/20250813/20119035YgS7dXKBmI.png
撈出team_id !=2的資料
https://ithelp.ithome.com.tw/upload/images/20250813/20119035Z1SIQYLTkH.png
撈出team_id 在2跟6用in
SELECT * FROM sampledatabase.sbl_team_data where team_id in (2,6)
https://ithelp.ithome.com.tw/upload/images/20250813/20119035M39zKC4e30.png
找出team_id 在2跟5之間
SELECT * FROM sampledatabase.sbl_team_data where team_id between 2 and 5
https://ithelp.ithome.com.tw/upload/images/20250813/20119035m6GzTrFjQl.png
點team_id欄位顯示^表示遞增排序
https://ithelp.ithome.com.tw/upload/images/20250813/20119035NceR4w64jc.png
找出season欄位有包含S1
SELECT * FROM sampledatabase.sbl_team_data where season like '%S1%'
https://ithelp.ithome.com.tw/upload/images/20250813/20119035ZW8a03w5Yp.png
找win欄位2開頭用2%
SELECT * FROM sampledatabase.sbl_team_data where win like '2%'
https://ithelp.ithome.com.tw/upload/images/20250813/201190353YaBdr6hU9.png
找win欄位2結尾用%2
SELECT * FROM sampledatabase.sbl_team_data where win like '%2'
https://ithelp.ithome.com.tw/upload/images/20250813/20119035OqobXgRIqB.png
找 lost欄位不是空值 NULL
然後season是S16
SELECT * FROM sampledatabase.sbl_team_data where lost is not null and season = 'S16'
https://ithelp.ithome.com.tw/upload/images/20250813/20119035eoSQrFZld7.png
新增 資料SQL
INSERT INTO sampledatabase.sbl_team_data (team_id, win) VALUES ('43', '3');

用,擺在一起可以節省效能
INSERT INTO sampledatabase.sbl_team_data (team_id, win) VALUES ('43', '3'), ('56', '3');
https://ithelp.ithome.com.tw/upload/images/20250813/20119035CSMrbrHHcX.png
按 重新整理
https://ithelp.ithome.com.tw/upload/images/20250813/201190352c14tAZmL6.png
討論資料庫關聯
新增表
https://ithelp.ithome.com.tw/upload/images/20250813/20119035FPDQtraadN.png
顯示 寫表名
https://ithelp.ithome.com.tw/upload/images/20250813/20119035r8811TN0v9.png
寫表的內容,按apply
https://ithelp.ithome.com.tw/upload/images/20250813/20119035r3pxGpD3Qz.png
旁邊按重新整理顯示
https://ithelp.ithome.com.tw/upload/images/20250813/20119035L0iZrc2acq.png
加入內容再按APPLY
https://ithelp.ithome.com.tw/upload/images/20250813/201190353yH5pxfWXo.png
顯示
https://ithelp.ithome.com.tw/upload/images/20250813/20119035ok0Gb4pVEQ.png
大家明天見~


上一篇
裝mysql
下一篇
資料庫關聯
系列文
Laravel 是甚麼30
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言