今天我学习了数据库一些相关的东西,对于刚刚学习数据库的同学可以试一下!!!
1:下面我们建立一张student3的表:
create table student3(
id int,
name varchar(20),
age int,
sex varchar(5),
address varchar(100),
math int,
english int
);
insert into student3(id,name,age,sex,address,math,english)
VALUES(1,'马云',55,'男','杭州',66,78),(2,'马化腾',45,'女','深圳',98,87),(3,'马景涛',55,'男','香港',56,77),(4,'柳岩',20,'女','湖南',76,65),(5,'柳青',20,'男','湖南',66,78),(6,'刘德华',57,'男','香港',99,99),(7,'马德',22,'女','香港',99,99),(8,'德玛西亚',18,'男','南京',56,65)
2:这里就是一些查询语句
>--查询年龄大于20岁的
>select * from student3 where age>20
>--查询年龄等于20岁的
>select * from student3 where age=20
>--查询年龄不等于20岁的
>select * from student3 where age!=20
>select * from student3 where age <> 20
>
>--查询年龄大于20,小于等于30的
>select * from student3 where age>=20&&age<=30
>select * from student3 where age>=20 and age<=30
>select * from student3 where age BETWEEN 20 and 30;
>
>--查询年龄22岁,19岁,25岁的信息
>select * from student3 where age=22||age=19||age=25
>select * from student3 where age in(19,22,25)
>
>--查询一下英语成绩为null的人
>select * from student3 where english=null; //这是错误的
>select * from student3 where english is null;
>
>--查询英语成绩不是null的
>select * from student3 where english is not null
>
>--查询其中姓马的有哪几个
>select * from student3 where name like '马%'
>
>alter table student3 change sex sexs varchar(110);
>
>--查询第姓名二个字是华的人
>select * from student3 name
>
>--查询姓名是3个子的人
>select * from student3 where name like '___'
>
>--查询姓名中包含'马的人'
>select * from student3 where name like '%马%'
>
>--查询姓名中包含德的人
>select * from student3 where name like '%德%'
3:点个关注不迷路