操作數(shù)據(jù)表中的記錄

插入記錄:

insert 表名 values();
自動編號的字段可以 賦值為nul 或 default

insert 表名 set 字段名 = “ ”;

將一個表的字段插入另一個表

insert 要插入的表(字段) select 插入的字段 from 原表 where 。。。。;

將users 插入 test 中
insert test (username) select username from users where age > 30;

單表更新:

update 表名 set 字段 = “ ”;
update 表名 set 字段 = “ ” , 字段= “ ”;

刪除記錄:

delete from 表 where 字段 = “”;

查詢表達(dá)式:

select 字段1,字段2.,,,, from 表 ;

起別名:

select 字段1 as 別名, 字段2 as 別名 ..... from 表;

條件表達(dá)式:

where

查詢結(jié)果分組:

select 字段 from 表 group by 字段;

對查詢結(jié)果排序:

select * from 表 order by id desc ;

限制查詢返回結(jié)果:

select * from 表 limit 2;

select * from 表 limit 2,3;

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容