删处表:drop table student;删除表数据:delete from student; 增加数据:insert into student (name,money,sex,phone) values ('hk',10000,'男',188); insert into student values('','小明',100,'',120);
修改数据:update student set money=100;#不指定条件,修改所有 update student set money=110 where name='hk';#只改hk查询数据:select * from students limit 1,5; #从第几条开始,下面的x条,不包含开始的那一条 select * from students where sex='男' and money>100; #多个条件,必须同时满足 select * fromstudents where addr like '%东京%';#模糊匹配,%代表的是通配符
SELECT * from students a where a.stu_name in ('牛牛','林倩','姚远');# inSELECT * from students a where a.money BETWEEN 1000 and 10000;#在什么什么之间的数据SELECT * from students ORDER BY money desc;降序是desc,升序asc默认是升序SELECT MAX(a.money) 钱最多 from students a; #最大值
SELECT AVG(a.money) 平均多少钱 from students a; #平均数
SELECT deptno,deptname FROM dept
UNION SELECT id,`name` FROM employee;联合查询
SELECT e.id,e.`name`,d.deptname FROM employee e RIGHT JOIN dept d ON e.`deptno`=d.`deptno`联接join查询