MySQL 是关系型数据库的一种,目前主流的是 ①oracle ②SQLserver ③MySQL,数据库的应用有哪些?sql
广深小龙公司目前也是使用Mysql 与非关系型数据库 NoSQL,SQL是结构化查询语言,MySQL开源、免费、支持多平台所以普遍被应用。数据库
语法顺序:select ... from... where.... group by... having... order by... limit服务器
一、表联结:inner join ... on并发
可多表联结,后面可接查询条件。oracle
select s.* from student s inner join info i on s.student_id=i.student_id;
二、子查询,相似嵌套性能
select * from student where id in(select student_id from info where phone='1333333333');
三、模糊查询:like '%查询内容%'学习
四、排序 or 倒序:order by ... desc测试
五、分组过滤查询:group by ... having 条件大数据
select *,count(*) from `student` group by age having count(*)>=2;
六、查询出最高年龄的信息,用到分页limit取倒序的第一个,注意:最高年龄可能会有重复spa
select * from student order by age desc limit 1;
七、修改语句:update
①普通语法:update student set age=20 where id =2;
②嵌套子查询给update语句:update student set age=20 where id in(select student_id from info where id=1);
固然还能够多种方法进行匹配。
八、插入语句:insert into 表(表字段1,表字段2) values(值1,值2)
①单个数据插入
insert into student (id, phone, age) values ('112', '18666666667', '23');
②多个数据插入:
insert into student (id, phone, age) values ('9', '18666666667', '23'),('10', '18666666667', '23');
固然还有其它不少经常使用的语法,好比建立表结构,插入数据等等,咱们平时可能都是不怎样用到删除 delete 语句,相信咱们的MySQL数据表设计都有一个相似假删除的字段。
还有一些关键字之类的,好比 is、not、as、and、or等等,如需更多请自行了解以下图或度娘:
最后附上两年前的笔记:
最后想使用图形化界面操做SQL,赠你免费破解Navicat 。
请到QQ交流群一块儿学习:482713805 !!!