_运算符
Posted 嫚嫚_
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了_运算符相关的知识,希望对你有一定的参考价值。
-- 第四章 运算符
SELECT 100, 100 + 0, 100 - 0, 100 + 50, 100 + 50 -30, 100 + 35.5, 100 - 35.5
FROM DUAL;
SELECT salary,employee_id ,last_name
FROM employees
WHERE employee_id %2=0;
-- 1:NULL ,IS NOT NULL,
SELECT 1 = 1, 1 = '1', 1 = 0, 'a' = 'a', (5 + 3) = (2 + 6), '' = NULL , NULL =
NULL;-- 字符串存在隐式转换,转换不成功就是0
SELECT 1 = 2, 0 = 'abc', 1 = 'abc' FROM DUAL;
--2:LEAST() GREATEST() 最小最大
SELECT LEAST('a','b','c'),GREATEST('a','b','c')
FROM DUAL;
SELECT LEAST(first_name,last_name),LEAST(LENGTH(first_name),LENGTH(last_name))
FROM employees;
-- between and
#查询工资在6000到8000的
SELECT employee_id ,last_name,salary
FROM employees
WHERE salary BETWEEN 6000 AND 8000
SELECT employee_id ,last_name,salary
FROM employees
WHERE salary NOT BETWEEN 6000 AND 8000
-- in(set) ,not in(set)
-- 查询部门30和10的姓名
SELECT last_name,salary,department_id
FROM employees
-- where department_id=10 or department_id =20
WHERE department_id NOT IN(10,20,30);
-- like 模糊查询
-- last_name 存在a的名字
-- % 代表不确定的字符(0,1或者多个)
SELECT last_name
FROM employees
WHERE last_name LIKE '%a%';
-- 查询第二个名字是a的员工信息
-- \\转义符
SELECT last_name
FROM employees
WHERE last_name LIKE '_a%';
-- regexp rlike 正则表达式
以上是关于_运算符的主要内容,如果未能解决你的问题,请参考以下文章