SELECT语句
单表查询
SELECT Column1, Column2
from table1
多表连接查询
SELECT table1.Column1,table2.Column2
from table1,table2
对选择可运算的列进行运算操作
select salary, salary * 2
from employees
NULL
NULL表示 不可用、未赋值、不知道、不适用,它既不是0 也不是空格。
给查询的列起别名
select last_name
AS name, employee_id id
from employees
select last_name AS "Name", salary * 2 "Annual Salary"
from employees
字符串连接操作符
SELECT last_name, job_id AS "Employees"
FROM employees;
SELECT last_name||job_id AS "Employees"
FROM employees;
SELECT last_name ||' is a '||job_id AS "Employee Details"
FROM employees;
DISTINCT
去除重复行
默认情况,返回所有行,包括重复行
SELECT department_id
FROM employees;
使用DISTINCT
消除重复结果行
SELECT DISTINCT department_id
FROM employees;