MySQL資料的增刪查改

2022-08-26 11:03:10 字數 689 閱讀 5069

一. 增加資料  insert into

1. 插入完整的資料

insert into 表名 values (欄位1的值,欄位2的值,......);

2. 給指定字段插入資料

insert into 表名(欄位2,欄位3,...) values (值2,值3,...);

3. 插入多條資料

insert into 表名 values

(欄位1的值,欄位2的值,欄位3的值,...),

(欄位1的值,欄位2的值,欄位3的值,...),

(欄位1的值,欄位2的值,欄位3的值,...);

4. 插入某一條查詢結果

insert into 被插入的表名 select from 被查詢的表名 where ...;

二. 更新資料  update

1. update 表名 set 

欄位1 = 值1,

欄位2 = 值2,

where condition;

三. 刪除資料  delect

1. delete from 表名 where 條件;

MySQL 增刪查改

目錄2 insert 3 update 4 delete 5 更新和刪除的指導原則 此語句使用select語句檢索單個列。limit 5指示 mysql 返回不多於 5 行。select prod name from products limit 5,5 limit 5,5指示mysql返回從行 5...

MySQL 增刪查改

create table ceshi1 uid varchar 50 primary key,pwd varchar 50 name varchar 50 1.最後一列不寫逗號 2.多條語句一起執行 分號分開 3.符號 英文狀態 1.主鍵 primary key 2.非空 not null 3.自增...

mysql增刪查改

語法 insert into 表名 欄位名1,欄位名2,values 值1,值2,舉例 insert into student id,name,grade values 1,zhangshan 98 若不指定欄位名,則新增的值的順序應和字段在表中的順序完全一致。語法 insert into 表名 v...