mysql常用语句

来源:互联网 发布:海量 top k算法 编辑:程序博客网 时间:2024/05/16 17:46

select * from table ORDER BY  字段  ASC  -- 根据时间从早到晚排序

select * from table ORDER BY 字段 desc  -- 根据时间从最新到旧排序

select * from  table -- 数据库查询

INSERT INTO table(表字段) VALUES ('内容')  -- sql插入语句

DELETE FROM table WHERE 条件    -- sql删除单条记录

UPDATE table SET  表字段  where 条件 -- 修改数据

SELECT *from table ORDER BY 表字段 desc  LIMIT 5   -- 查询最新的5条数据

SELECT * FROM table where 表字段 like'%值%'  -- 模糊查询

SELECT COUNT(*) from table   -- 查询数据总数

select * from table1 join table2 on table1.id = table2.id    -- 通过id进行内连接

select * from table1 cross  join table2 on table1.id = table2.id    -- 通过id进行交叉连接

原创粉丝点击