select
教程:https://www.bilibili.com/video/BV1GP4y1h7Zj?p=21
select 列名
from 表名
切换数据库:use 库名
select *(*代表所有列)
select first_name,email
from employees;
选中部分列,列名之间用,
连接
别名
- SQL中,只有给列起别名时才用""
- 别名可以使用双引号,也可以不使用双引号,但是如果别名包含空格或者特殊字符时,则必须使用双引号
- as 可以省略不写
空值问题
SQL中,空值参与运算,结果还是空值
解决措施ifnull(commission_pct,o)
去重(distinct)
select distinct job_id
from employee;
显示表结构
describe employees;
简写 desc employees;
过滤和排序
select *
from employees
where department_id = 90;
where 子句紧随from子句。