SQL语句 运算符
6.2 运算符
6.2.1 算术运算符
加 / 减 / 乘 / 除
6.2.2 连接运算符
是用来连接字符串的。跟java中的 + 是一致的。
select 'abc' || ' bcd ' as 连接后的结果 from dual;
select d.dname || ' 部门' from dept d;
6.2.3 比较运算符
> / < / >= / <= / != / <> /IS NULL / Like / Between / In / Exsist
-- 判断 null 值
select * from n5 where s is null;
select * from n5 where s is not null; -- like 模糊查询。慎用,有可能会导致全表扫描,效率低。
-- % 匹配0到多个字符,_ 匹配一个字符
select username from dba_users where username like 'VI_';
select username from dba_users where username like 'SC%';
select username from dba_users where username like '%SC%'; -- in,是 where x = a or x = b or x = c 的一种缩写。下面两条是等价的。
select * from emp where empno in (700, 800, 900);
select * from emp where empno = 700 or empno = 800 or empno = 900;
-- in 后面跟的不一定是逗号分隔的单项,也可能是一个完整的查询语句。
-- 下面两条结果是一致的
-- 这种 in 慎用
select * from emp where deptno in (select deptno from dept where dname = 'SALES');
select a.* from emp a,dept d where a.deptno =d.deptno and d.dname='SALES'; -- between...and
select * from emp where empno between 7800 and 9000;
-- 等同于:
select * from emp where empno >= 7800 and empno <= 9000;
6.2.4 逻辑运算符
and / or / not
not 的优先级 > and 的优先级 > or 的优先级
6.2.5 集合操作符
Union / UnionAll / Intersect / Minus
-- 生成测试数据
create table dept_01 as select * from dept where rownum < 6;
create table dept_02 as select * from dept where rownum < 4;
insert into dept_02 values (98, '小吃部', '斗门');
insert into dept_02 values (99, '外卖部', '香洲');
commit; select * from dept_01
union
select * from dept_02; select * from dept_01
union all
select * from dept_02; select * from dept_01
intersect
select * from dept_02; select * from dept_01
minus
select * from dpet_02;
SQL语句 运算符的更多相关文章
- LINQ体验(13)——LINQ to SQL语句之运算符转换和ADO.NET与LINQ to SQL
运算符转换 1.AsEnumerable:将类型转换为泛型 IEnumerable 使用 AsEnumerable<TSource> 可返回类型化为泛型 IEnumerable 的參数.在 ...
- 年终巨献 史上最全 ——LINQ to SQL语句
LINQ to SQL语句(1)之Where 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子句.Where操 ...
- MYSQL 基本SQL语句
复制表结构 CREATE TABLE 新表 SELECT * FROM 旧表 where 1=2 复制表结构和数据CREATE TABLE 新表 SELECT * FROM 旧表 查询重复数据: se ...
- SQL语句
数据查询:SELECT 以下所有的查询都基于以下的表格: 学生表:STUDENT(SNO,Sname,ssex,sage,sdept); 课程表:course(cno,cnama,cpno,ccred ...
- 练习用基础SQL语句
http://www.cnblogs.com/zxlovenet/p/3728842.html 本文语句大部分SQL语句来自<数据库系统概论>(第四版)王珊&萨师煊 ,是我们上课用 ...
- Entity FrameWork 5 增删改查 & 直接调用sql语句
class="brush:csharp;gutter:true;"> #region 1.0 新增 -void Add() /// <summary> /// 1 ...
- SQL语句经典大全
一.基础 1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- ...
- SQL语句大全
经典SQL语句大全(绝对的经典) 一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份s ...
- 个人查阅资料-Sql语句
SQL分类: DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE) DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT) DCL—数据控制语言(GRAN ...
随机推荐
- web开发(三) 会话机制,Cookie和Session详解
在网上看见一篇不错的文章,写的详细. 以下内容引用那篇博文.转载于<http://www.cnblogs.com/whgk/p/6422391.html>,在此仅供学习参考之用. 一.会话 ...
- 阶段3 2.Spring_08.面向切面编程 AOP_4 spring基于XML的AOP-配置步骤
resources下新建bean.xml文件 xmlns:aop 先配置IOC aop 通知类就是logger.id配置为logAdvice表示日志的通知 梳理流程 首先我们在这有个Service它需 ...
- 递归选中easyui树
$(function(){ // var data1 = [ // { // "id": 3, // "text": "3组织", // & ...
- 删除delphi组件TStringlist中的重复项目
https://blog.csdn.net/ozhy111/article/details/87975663 删除delphi组件TStringlist中的重复项目 2019年02月27日 15:41 ...
- java:CSS(定位,组合选择符,边距,Float,Table的样式,显示和隐藏,换行,盒子模型,iframe和frameset框架)
1.绝对定位,相对定位,fixed定位(指浏览器窗口定位): <!DOCTYPE html> <html> <head> <meta charset=&quo ...
- linux c++ 实现http请求
main.cpp #include HttpReq.h #include <string.h> int main(void) { HttpRequest* Http; char http_ ...
- MSF魔鬼训练营第一章 初识Metasploit
1.1.4渗透测试过程环节 PTES标准7个阶段 1.前期交互阶段 收集客户需求.准备测试计划.定义测试范围与边界.定义业务目标.项目管理与规划等 2.情报搜集阶段 公开来源信息查 ...
- windows VS2013中使用<pthread.h>
1. 下载pthreads-w32-2-9-1-realease.zip 地址:http://www.mirrorservice.org/sites/sourceware.org/pub/pthrea ...
- springboot - 应用实践(1)认识springboot
1.为什么要推出springboot springboot设计的目的是用来简化新spring应用的初始搭建以及开发过程.springboot遵循“约定优于配置”原则. 2.springboot默认的配 ...
- Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org ...