Day44 数据库的操作
视图操作:
1.左连接查询
select * from person left join dept on person.dept_id = dept.did
2. 右连接
3. 内连接 inner join
4. UNION ALL 全连接
=======================
一 、 多表操作
select * from person,dept
二 、多表联合操作
select * from person,dept where person.dept_id =dept.did
select * from person,dept where person.dept_id =dept.did and person.salary >3000
三、多表连接查询
左连接查询 (以左表作为基准)
select *from person left JOIN dept on person.dept_id = dept.did
内连接查询
select * from person inner JOIN dept where person.dept_id =dept.did
4.全连接查询 full JOIN
select * from person LEFT JOIN dept ON person.dept_id = dept.did
UNION ALL
select * from person RIGHT JOIN dept on person.dept_id = dept.did;
二 、 复杂的多表查询 。
1. 查询出 教学部 年龄大于20岁,并且工资小于40000的员工,按工资倒序排列.(要求:分别使用多表联合查询和内连接查询)
select * from person inner join dept on person.dept_id = dept.did and dept.dname = '教学部' and person.age >20 and salary <40000 order by person.salary asc
2.查询每个部门中最高工资和最低工资是多少,显示部门名称
select dept.dname , MAX(salary),MIN(salary) from person LEFT JOIN dept on person.dept_id =dept.did group by person.dept_id
2.求最大工资那个人的姓名和薪水
1.求最大工资
select max(salary) from person;
2.求最大工资那个人叫什么
select name,salary from person where salary=53000; 合并
select name,salary from person where salary=(select max(salary) from person);
3. 求工资高于所有人员平均工资的人
1.求平均工资
select avg(salary) from person; 2.工资大于平均工资的 人的姓名、工资
select name,salary from person where salary > 21298.625; 合并
select name,salary from person where salary >(select avg(salary) from person);

Day44 数据库的操作的更多相关文章
- php模拟数据库常用操作效果
test.php <?php header("Content-type:text/html;charset='utf8'"); error_reporting(E_ALL); ...
- Android-Sqlite数据库的操作
Sqlite数据库的简单操作: 设置增删改查的按钮,xml界面布局设置 <?xml version="1.0" encoding="utf-8"?> ...
- (四)SQL入门 数据库的操作与事务管理
数据库的操作,有三个最基本的语句,insert插入,update修改,delete删除. 不同的数据库厂商的实现可能不同,所以就不说具体的语法怎么写的了.说语法也没有意义,到处都可以复制粘贴,记得听某 ...
- Laravel框架数据库CURD操作、连贯操作使用方法
Laravel框架数据库CURD操作.连贯如何来操作了这个操作性是非常的方便简单了我们在这里来为各位介绍一篇相关的教程,具体的细节步骤如下文介绍. Laravel是一套简洁.优雅的PHP Web开 ...
- zabbix数据库mariadb从服务器迁移到云mysql数据库的操作
zabbix数据库mariadb从本机迁移到云mysql数据库的操作 1.将zabbix数据库导出,并导入到云数据库中 由于数据库较大,如果直接使用shell会话中断会导致数据库导出或者导入失败,使用 ...
- 使用my exclipse对数据库进行操作(4)
四.删除 public class class4 { public static void main(String[] args) { // TODO Auto-generated method st ...
- 从C#到Objective-C,循序渐进学习苹果开发(7)--使用FMDB对Sqlite数据库进行操作
本随笔系列主要介绍从一个Windows平台从事C#开发到Mac平台苹果开发的一系列感想和体验历程,本系列文章是在起步阶段逐步积累的,希望带给大家更好,更真实的转换历程体验.本篇主要开始介绍基于XCod ...
- MYSQL数据库的操作
Mysql的连接方式: 1.原生函数:mysql_connect($server,$username,$password); //打开一个到Mysql服务器的连接 mysql_select_db( ...
- DBA必备:MySQL数据库常用操作和技巧
DBA必备:MySQL数据库常用操作和技巧 2011-02-25 15:31 kaduo it168 字号:T | T MySQL数据库可以说是DBA们最常见和常用的数据库之一,为了方便大家使用,老M ...
随机推荐
- ROS学习笔记三(理解ROS节点)
要求已经在Linux系统中安装一个学习用的ros软件包例子: sudo apt-get install ros-indigo-ros-tutorials ROS图形概念概述 nodes:节点,一个节点 ...
- linux 下 php 安装 Gearman
Gearman是一个分发任务的程序框架,它会对作业进行排队自动分配到一系列机器上.gearman跨语言跨平台,很方便的实现异步后台任务. 一个Gearman请求的处理过程涉及三个角色: Clien ...
- Spring框架的IOC核心功能快速入门
2. 步骤一:下载Spring框架的开发包 * 官网:http://spring.io/ * 下载地址:http://repo.springsource.org/libs-release-local/ ...
- 阈值分割与XLD轮廓拼接——第4讲
一.阈值分割 阈值分割算子众多: threshold :这是最基本最简单的阈值算子. binary_threshold :它是自动阈值算子,自动选出暗(dark)的区域,或者自动选出亮(light)的 ...
- Halcon对文件的创建、读取、写入、删除等操作总结
Halcon可以操作普通文本文件,也可以操作二进制文件.如下图所示,只需要设置“FileType”参数的取值即可明确是操作文本文件还是二进制文件: 下面的程序是操作一个.txt文本文件的完整代码: * ...
- 201621123008 《Java程序设计》第二周学习总结
1. 本周学习总结 通过查询API掌握了一下几种类的基本用法: String类 StringBuilder类 ArrayList类 BigInteger类 BigDecimal类 Arrays类 认知 ...
- msys2 启用windows PATH环境变量
有三种方法修改 ①msys2_shell.cmd 中取消一行的注释:set MSYS2_PATH_TYPE=inherit ②调用msys2_shell.cmd时使用-use-full-path参数 ...
- 【C#】VS2015开发环境的安装和配置(转)
出处: http://www.cnblogs.com/rainmj/p/5636518.html http://www.cnblogs.com/rainmj/p/5636529.html http:/ ...
- 删除k8s中一直处于Terminating的资源
1.将所有的etcd中的key值取到一个keys.yam里面,便于查询 ETCDCTL_API=3 etcdctl get "" --from-key > keys.yaml ...
- HDU2212 DFS 2016-07-24 13:52 56人阅读 评论(0) 收藏
DFS Problem Description A DFS(digital factorial sum) number is found by summing the factorial of eve ...