[第九週] MySQL 語法基礎


Select 查詢資料

SELECT 欄位名稱 FROM table 名稱

// 從 members 裡查詢 id 跟 phone 的資料
SELECT id, phone FROM members

SELECT * FROM table 名稱 查詢表格內全部的資料

SELECT phone as mobile FROM table 名稱 改變欄位名稱(phone 變成 mobile),但不改變內容

SELECT * FROM members where name = 'peter' 使用 where 查詢 name = peter 的全部資料

Insert 新增資料

INSERT INTO 表名 (欄位名1,欄位名2, …) VALUES (“欄位1的值”,”欄位2的值”, …)

// 新增一筆資料到 members 的表格裡
INSERT INTO members (name, phone) VALUES ("Andy" , "0922808178")

Update 修改資料

UPDATE table_name SET column_name = new_value WHERE column_name = some_value

// 修改 Andy 那筆資料裡的 age
UPDATE members SET age = "30" WHERE name = "Andy"

Delete 刪除資料

DELETE FROM table_name WHERE column_name = some_value

#MySQL






你可能感興趣的文章

[Power BI] Data Modeling #2

[Power BI] Data Modeling #2

宜蘭遊 1th  feat.台北

宜蘭遊 1th feat.台北

Week3 - 挑戰題:貪婪的小偷 Part2

Week3 - 挑戰題:貪婪的小偷 Part2






留言討論