1、查询所有姓张学生的数量
1、展示详情
select * from tablex where name like
"张%";
2、展示数量
select count(*)
from tablex where name like
"张%";
2、取出计算机考试步程计的学生,并倒序排序
select * from tabley where score<60 order by desc;
3、通过外联,取出每个学生的name、class、score
左外链接 left join
select name,class,score from tablex a left join tabley b on a.code=b.code
4、添加数据
insert into tablex values('97005','赵六','20');
1、使用sql向员工信息表中调价数据
insert into 表名 values('001','张三','男','010-62570007','北京市海淀区')
2、使用sql查询出亲属数量大于1的员工编号,姓名,亲属数量
select a.codccode,a.codename,b.count(recodename) from a left outer join b on a.emp_id=b.emp_id
小米测试题
1、下列那种请求方法输入http协议
https://blog.csdn.net/macroway/article/details/1428541
2、某文件的权限为drw-r-r--,用数值形式表示该权限,则该八进制数为?
https://blog.csdn.net/Wisteriapcp/article/details/46316583
3、查看当前服务器的剩余磁盘空间?查看磁盘内存使用情况?
https://blog.csdn.net/qq_35070673/article/details/88258641
4、使用sql查询购买goods_id为1001的用户user_id;
select user_id from orderb b left join ordera2 a on a.order_id=b.order_id where goods_id=1001;
5、用sql查询2017年7月1号够买1001这个商品的信息,user_id,order_id,goods_id,price
select * from orderb b left join ordera2 a on a.order_id=b.order_id where add_time>2470 and b.goods
_id=1001;
6、用sql查询出订单所包含商品的明细总金额大于50的order_id和user_id
select * from orderb b left join ordera2 a on a.order_id=b.order_id where price>=50;
1、计算每个人的总成绩并排名
select name,sum(score) from student group by name order by score;
2、计算每个人的总成绩并排名(要求显示字段: 学号,姓名,总成绩)
select name,sum(score),stid from student group by name order by score;
3、计算每个人单科的最高成绩(要求显示字段: 学号,姓名,课程,最高成绩)
4.使用sql语句查询出表中的所有内容
select * from student4;
5.使用sql语句查询出表中所有同学的id,name,score
select id,name,score from student4;
6.更改useremail字段的数据类型为varchar(50)
alter table student4 modify column useremail varchar(50);
7.向表中添加一个字段,字段名称为“pingjia”,字段类型为varchar(20)
alter table student4 add pingjia varchar(20);
8.更改姓名是张三的同学的分数为88
update student4 set score=88 where name='张三';
9.如果80分为及格线,查询出所有及格的同学的详细信息
select * from student4 where score>=80;
10.把姓名是“小红”的同学的分数在原来的基础上+40
update student4 set score=score+40 where name='小红';
11.使用关键字in,查询id值是1或5或7的同学的基本信息
select *from student4 where id in(1,5,7);
12.查询id值在5至8的所有同学的基本信息
select *from student4 where id>=5 and id<=8;
13.查询姓名是小红并且分数大于60的同学的基本信息
select *from student4 where name='小红' and score>60;
14.查询姓名是小红或者分数大于90的同学的基本信息
select *from student4 where name='小红' or score>90;
15.查询score字段值是NULL的同学的基本信息
select * from student4 where score is null;
16.查询score字段值不是NULL的同学的id和name
select * from student4 where score is not null;
-设置默认值
alter table 表名 alter column 字段名 set default 默认值;
:sid设置为主键自增长
3.2:sname设置非空约束
3.3:sex设置默认值为男
3.4:Job设置为非空约束
create table yuangong(sid int primary key auto_increment,sname varchar(50) not null,sex varchar(30),job varchar(50) not null,birthday varchar(50),salary int,comm int,withhold int
);
1、选择db_test数据库
use db_test
2、修改表名为“emp”
lter table yuangong rename AS emp;
3、向表中添加字段Hobby,设置类型为varchar(50),设置唯一约束(10分)
alter table emp add hobby varchar(50) unique;
4.使用desc语句查看表结构(5分)
desc emp;
5、向表中添加记录,字段对应值分别为(1005,林青霞,女,架构师,1969-12-12,8000,NULL,100,阅读)
insert into emp values(1005,'林青霞','女','架构师','1969-12-12',8000,0,100,'阅读');
6.修改sname字段的类型为varchar(20)(5分)
alter table emp modify column sname varchar(20);
7、查询表中sid字段的值从是1002或1003或1005员工的所有记录(使用关键字in)
select * from emp where sid=1002 or sid=1003 or sid=1005;
8.修改表中job值是高级工程师员工的job为“架构师”(5分)
update emp set job='架构师' where job='高级工程师';
9.删除表中sid是1003并且job是王五的员工的记录(10分)
delete from emp where sid=1003 and job='王五';
10.修改表中姓名是1004员工的salary在原来的基础上-300(10分)
update emp set salary=salary-300 where name='1004';
1、查询所有图书的信息,并按价格降序显示
select * from book order by price desc;
2、查询所有作家出版社的图书信息,并按价格降序显示
select * from book where publish='作家出版社' order by price desc;
3、查询出所有刘和平的图书信息 ,并输出。
select * from book where author='刘和平';
4、删除ID是2的记录,如果没有相关记录则提示
delete from book where id=2;
5、将所有价格不足10元的图书调到10元,并查看信息
update book set price=10 where price<10;
6、查看所有图书的价格情况,并升序显示
select price from book;
7、查看所有价格低于20元的图收信息
select * from book where price<20;
8、所有图书的价格上调20%,并查看信息
update book set price=price*1.2;将王五的工资涨100元
update UserInfo set Salary=Salary+100 where UserName=‘王五’;
写一个select语句,找出人数超过2个人的部门
select * from UserInfo group by Dept;
select subject,count(subject) from student group by subject having (count(subject)>=2);
表一 user:用户 id(userid),用户名(name),性别(sex)
表二 order:订单 id(orderid),用户id(uid),商品id (tid)
表三 reviews:评价id(reviewsid),订单id(oid),评价内容(assess)
查询当前所有用户下单信息?
select * from user as u inner join order as o on u.userid=o.uid;
查询用户名为张三的所有订单评价(三表联查)?
select r.assess from reviews as r inner join order as o on r.oid=o.orderid inner join user as u on o.uid=u.userid where u.name='张三';
select assess from reviews where oid=(select orderid from order where uid = (select userid from user where name='张三'));
mysql查询所有姓张 mysql查询姓张的学生人数
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章