# 「取什么」填写 * 取全部或填写列名(多个用逗号分隔)来取出指定字段
# 列名也可使用函数表达式
SELECT `要取出的列名`,`要取出的列名` FROM `表名`;
# 可以为取出的列设定别名(常用于函数计算结果)
SELECT
`要取出的列名`,
`要取出的列名` AS `别名`
FROM `表名`;
有以下几种条件可以选择
=
精确匹配与 like
模式匹配
%
表示匹配任意_
表示占位符=
<>
<
>
is null
与 is not null
between A and B
(包括前后界)in (值1, 值2, 值3, …)
and
or
not
SELECT `列名` FROM `表名` WHERE 条件;
SELECT ... FROM `...` ORDER BY xx [asc]; -- 升序
SELECT ... FROM `...` ORDER BY xx desc; -- 降序
SELECT ... FROM `...` LIMIT x; // 取前 x 个
SELECT ... FROM `...` LIMIT x, y; // 取第 (x, y] 个
# 基础数值运算
SELECT
name, price AS old_price, price + 10 AS new_price
FROM
products
WHERE
name IS NOT NULL;