SQL 基本增刪改查

2021-09-20 10:09:52 字數 1128 閱讀 1169

1.增——關鍵字 insert

insert into 表名 (列1,列2…) values (值1,值2…);

例如:

insert into test (name,age,phone ,record_time) values ('lily','14','13199999999','0019-04-23 00:00:00');
2.刪——關鍵字 delete

delete from 表名 where 條件;

注意:在用delete的時候一定!一定!!要加條件!!!

例如:

delete from test where name='lily';
3.改——關鍵字 update

update 表名 set 列名1=值1,列名2=值2…where 條件;

例如:

update test set age='15' , record_time='0019-04-23 05:00:00'    where name='lulu';
4.查——關鍵字 select

select * from 表名;

select * from 表名 where 條件;

select 列1,列2… 表名 where 條件;

例如:

select * from test;

select * from test where age >10;

select name,age,phone where age>10;

擴充套件 :

(1)關鍵字 limit (限制的條數)

select * from 表名 limit 行數;

例如:

select * from test limit 1 ;
(2)關鍵字asc(公升序)和desc(降序)

select * from 表名 order by 列名 asc;

select * from 表名 order by 列名 desc;

例如:select * from test order by record_time asc;

select * from test order by record_time desc;

SQL基本增刪改查語句

資料庫的基本操作 增刪改查 crud create retrieve update delete 建立表 create table info id integer primary key,name varchar 20 age varchar 20 增insert into info name,ag...

sql基本語句 增,刪,改,查

select 語句用於從表中選取資料。結果被儲存在乙個結果表中 稱為結果集 select 列名稱 from 表名稱 where 列名稱 某值 或select from 表名稱 where 列名稱 某值insert into 語句用於向 中插入新的行。insert into 表名稱 values 值1...

SQL 增刪改查

之前大致了解過,現在用 mysql 的還是居於多數,而且自己之後也有意嚮往大前端發展,所以就需要撿起以前的 sql,也希望將來有機會用 node.js mysql 做大型專案的機會。因此,就從簡單的 sql 的增刪改查開始大前端之路。開發中最常見的就是 select 查詢。簡單的查詢,看起來是這樣的...