一、实验目的
1、熟悉MySQL和Navicat的使用。
2、理解SELECT语句的操作和基本使用方法。
3、理解JOIN语句的操作和基本使用方法,掌握内连接、外连接、自身连接的概念和使用
4、掌握视图的定义与工作原理。
5、掌握使用SQL插入、删除和修改数据表数据的方法
二、实验内容
1) 查找出职称为职员的女员工的姓名、职称、性别。
select emp_name,title,Sex from employee where title='职员'and Sex='F'
2) 查找出employee表中与‘周小梅’住址相同的员工的姓名、性别、职称、薪水、住址。
select emp_name,Sex,title,salary,Addr from employee where addr=(select Addr from employee where emp_name='周小梅')
3) 由employee表中查找出薪水最高的员工信息。
select * from employee where salary=(select max(salary)from employee)
4) 查询出employee表中所有女职工的平均工资和住址在"上海市
市"的所有女职工的平均工资
1. select avg(salary) from employee where Sex='F';
2.select avg(salary) from employee where Sex='F' and Addr='上海市';
5)计算出sale_item表中每一笔销售数据的销售金额,并按照销售金额的大小排序。
select Prod_id,Qty,Unit_price,(Qty*Unit_price) as tot_amt from sale_item
order by tot_amt desc
6)检索product 表和sale_item表中数量大于2的相同产品的产品编号、产品名称、数量、单价。
select order_no,Prod_id,Qty,Unit_price from sale_item where Qty>2;
7) 查找所有经理的姓名、职称、薪水。
select emp_name,title,salary from employee where title='经理'
8)查找出姓“王”并且名字的最后一个字为“功”的员工
select *from employee where emp_name like '王_功'
9)查找住在上海或北京的女员工,并显示其姓名、所属部门、职称、住址。
select emp_name,Dept,title,Addr from employee
where Addr like '北京%'or Addr like '上海%' and Sex like 'F'
10)在表sales中挑出销售金额大于等于10000元订单。
select *from sales where tot_amt>=10000;
10)在表sales中挑出销售金额大于等于10000元订单。
select