数据库的增删查改sql
标题1. 数据库的介绍
部门dept的数据库:
产品车的品牌brand的数据库:
员工staff的数据库:(deptid是外键来自dept)
客户customer的数据库:(staffid是外键来自staff)
产品production的数据库:(brandid是外键来自brand)
订单order的数据库:(有很多外键)
2.有关数据库的一些操作的sql编写
2.1 单表查询
(1)查询dept的全部信息
select * from dept ;
(2)通过dept的编号deptid=1查询编号为一的部门信息
select * from dept where dept.deptid = 1;
(3)查询以“王”开头,且倒数第3个字符为“航”的员工的详细情况
select * from staff where staff.sname like '王%航_';
(4)查询名字中有倩的女员工(模糊查询中任意位置上有倩)
select * from staff where staff.sname like '%倩%' and staff.ssex = '女';
(5)分页中:查询staff数据库中一共有多少条数据。
select count(*) from staff;
(6)查询汽车中超过所有汽车商品的平均售价的各个商品号和售价
select p1.productid,p1.pout from production p1
where p1.pout>(
select AVG(p2.pout) from production p2
) ;