day01/sql/sql操作.sql

36 lines
1.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 1.依据上图字段类型一致创建数据库添加至少5条数据。10分
INSERT INTO `rik01`.`emp`
(`ename`, `sex`, `tel`, `class_id`, `age`, `sal`)
VALUES
('1', '1', '1', 1, 1, 1.00),
('2', '1', '1', 1, 1, 1.00),
('3', '1', '1', 1, 1, 1.00),
('4', '1', '1', 1, 1, 1.00),
('5', '1', '1', 1, 1, 1.00);
-- 2.查询所有学生信息并根据年龄进行降序排序。10分
SELECT * FROM emp ORDER BY age desc;
-- 3.显示姓王的学生的详细信息。10分
SELECT * FROM emp WHERE ename LIKE CONCAT('%','','%')
-- 4.查询工资大于5000的所有男同学的信息。10分
SELECT * FROM emp WHERE sal > 5000
-- 5.查询班级编号为20的男同学的电话号码。10分
SELECT * FROM emp where class_id = 20
-- 6.查询最低工资。10分
SELECT min(sal) FROM emp
-- 7.查询班级为30的学生的最小年龄。10分
SELECT MIN(age) from emp where class_id = 30
-- 8.查询女生的最低工资。15分
SELECT MIN(sal) FROM emp where sex = ''
-- 9.查询女学生中薪资最低的人的全部信息。15分
SELECT * FROM emp where sex = '' AND sal = (SELECT MIN(sal) FROM emp where sex = '')