标签:转义 条件查询 pre on() 基础 iss mys 姓名 sql
1.查询单个字段
select last_name from employees;
2.查询多个字段
select last_name,salary,email from employees;
3.查询所有字段
select * from employees;
4.查询常量值
select 100;
select "john";
5.查询表达式
select 100*90;
6.查询函数;
select version();
7.字段起别名
select lase_name as “姓”,first_name as "名" from employees;
8.去重
select DISTINST department_id from employees;
9.字段连接
select CONCAT(last_name,first_name) as "姓名" from employees;
10.条件查询
select * from employees where salary>12000;
select last_name,department_id from employees where department_id != 90;
select last_name,department_id from employees where salary>10000 and salary<20000;
like:
SELECT * FROM employees where last_name LIKE ‘%a%‘;(模糊查询,%包括任意多个字符,_为任意单个字符,\为转义符号)
SELECT * FROM employees where last_name LIKE ‘__e%‘;
between and
select * from employees where employee_id BETWEEN 100 and 120;
in
select * from employees where job_id in ("IT_PROT","AD_VP","AD_PRES");
is null
SELECT last_name commission_pct from employees where commission_pct is null;
SELECT last_name commission_pct from employees where commission_pct is not null;
安全等于
SELECT last_name commission_pct from employees where commission_pct <=> null;
标签:转义 条件查询 pre on() 基础 iss mys 姓名 sql
原文地址:https://www.cnblogs.com/peterWXM/p/12989832.html