1. 程式人生 > 資料庫 >四種簡單的sql語句(增刪改查語句)

四種簡單的sql語句(增刪改查語句)

一、插入語句

insert into [table] ([column],[column],[column])
values(?,?,?)

二、刪除語句

delete 
from [table]
where column = ?

三、修改語句

update [table]
set column = ?
where column = ?

四、查詢語句

1)查詢單條記錄的所有欄位

select *
from [table]
where [column] = ?

2)查詢所有記錄的所有欄位

select *
from [table]
order by [column] asc

注意:

1.order by column asc代表:以column欄位,升序排列。desc為降序

3)查詢給定偏移量的記錄的所有欄位

select *
from [table]
limit [offset], [limit]

注意:

1.offset指定從哪個索引開始,預設從0開始

2.limit指定查詢幾條記錄

4)查詢指定記錄的指定欄位

select [column], [column]
form [table]
where [column] = ?