数据库常用语句
增
insert into 表名 values(数据);
insert into student values(1,'张三');
insert into student values(3,'王五'),(4,'赵六');
insert into student(name) values('小美');
删
detele from 表名 where 列名=(数据);
delete from student where name = '孙悟空';
删除孙悟空
改
update 表名 set 列名 = 数据;
update student set age= 25 where name = '孙悟空';
孙悟空年龄改成25
update student set set age = 25,hobby= 60 where name = '孙悟空';
查
select * from 表名;
select * from student;
select 列1,列2,列3..... from 表名;
select id,name,age from student;
select name,age from student where age<30;
查询年龄小于30的
select name,age from student where age between 20 and 30;
查询年龄20-30的
select * from student where name like '孙_';
查询姓孙二个字名字的人
select * from student order by age DESC;
年龄降序排列,ASC是升
内外连接查询
select student.name as studentName,class.name as className #从学生表中选择学生名字、课程表中选择课程名字 from student inner/left/right join class on class.id = student.class_id;