1、常见数据库
Oracle、MySQL、SQLServer、MongoDB(json格式)、Redis、Neo4J、SQLite
2、SQL语句分类
1)DDL-数据库定义语言
2)DML - 数据库操作语言
插入数据(insert into student values(1,’zhangsan’,’nan’,19,389.10,’1999-10-10’);)
删除数据(delete from student where id=1;)
修改数据(update student set salery=100.01,birthday=’1999-10-10’ where id=3;)
3)DQL-数据库查询语言
select * from student where math>80 and english>80 and chinese>80;
select * from student where name like ‘%张%’;(含有张)
select * from student order by math desc;(降序)
select * from student order by math desc limit m,n;(其中m是指记录从m+1开始,,N代表n条数据。例如:从第一天就是【0,几】)
select * from employee groupby sex having age>18;
创建学生表
create table student (id int primarykey auto_increment,name varchar(20),sex varchar(20),class_idint,constraint foreign key(class_id) references class(id));
select * from student where id in (select student_id from teacher_student where teacher_id=(select id from teacher where name='李老师' ));
2、连表查询
分类:内连接、外连接、交叉连接
1)内连接,inner join on
select * from customer c inner join orders o on c.id=o.customer_id;
2)左外连接,left join on(左外连接 left join on 设定条件,将两张表对应的数据查询出来,同时将左表自己没有关联的数据也查询出来)
select * from customer c left join orders o on c.id=o.customer_id;
3)右外连接, right join on (右外连接 right join on 设定条件,将两张表对应的数据查询出来,同时将右表自己没有关联的所有数据查询出来)
select * from customer c right join orders o on c.id=o.customer_id;
黑窗口:
登录:mysql-uroot -p 密码:*