Loading

sql常用语法大全

新增语句

INSERT INTO  [table] ([column],[column],[column]) VALUES(?,?,?)

删除语句

DELETE FROM [table] WHERE [column] = ?

DELETE FROM vod WHERE id= 1

修改语句

UPDATE [table] SET [column] = ? WHERE [column] = ?

查询语句

查询单条记录的所有字段

SELECT * FROM [table] WHERE [column] = ?

查询所有记录的所有字段

//  asc代表:以column字段,升序排列。desc为降序
SELECT * FROM [table] ORDER BY [column] ASC

分页查询

// 1.offset指定从哪个索引开始,默认从0开始
// 2.limit指定查询几条记录
SELECT * FROM  [table] LIMIT  [offset], [limit]

查询指定记录的指定字段

SELECT  [column1], [column2] FROM [table] WHERE [column1] = ?

随机抽取N条

SELECT  *  FROM  [table] ORDER BY RAND() limit 20
posted @ 2020-06-15 13:57  十年歧路  阅读(387)  评论(0编辑  收藏  举报