mysql常用语句
创建表
CREATE TABLE table_name (NAME VARCHAR(255),age int);
插入数据
INSERT INTO tb(name,age)VALUES('tom',18);
查询数据
SELECT * from project_project WHERE create_user='admin' ORDER BY create_time DESC LIMIT 10 OFFSET 1;
SELECT * from project_project WHERE create_time>'2019-01-17'
SELECT * from project_project WHERE create_user LIKE '%ht';
SELECT create_user from project_project UNION SELECT username from auth_user DISTINCT;
SELECT * FROM project_project ORDER BY create_time DESC;
SELECT create_user ,count(pro_name)FROM project_project GROUP BY create_user ;
select *from project_project INNER JOIN auth_user ON project_project.create_user=auth_user.username;
left join 左边的表保留全部数据,right join 右边的表保留全部数据
DISTINCT: 可选,删除结果集中重复的数据。默认情况下 UNION 操作符已经删除了重复数据,所以 DISTINCT 修饰符对结果没啥影响。 ALL: 可选,返回所有结果集,包含重复数据。
更新数据
UPDATE project_project SET pro_name='ios1',receive_mail='mail@test.com' WHERE id=22;
删除数据
DELETE FROM project_project WHERE id=22;