查找记录:
SELECT select_expr [,select_expr ...]
[
FROM table_references
[WHERE where_comdition]
[GROUP BY {col_name|position} [ASC|DESC],...]
[HACING where_comdition]
[ORDER BY {col_name|expr|position} [ASC|DESC],...]
[LIMIT {[offset,] row_count|row_count OFFSET offset}]
]
查询表达式(select_expr)
1、每一个表达式想要的一列,必须至少一个,多个列之间以英文逗号分隔

2、星号(*)表示所有的列
3、查询表达式可以使用[AS] alias_name 为其赋予别名,别名可用于GROUP BY,ORDER BY 或HAVING句子

WHERE 条件表达式
对记录进行过滤,如果没有指定where子句,则显示所有记录
在where表达式中,可以使用MYSQL支持的函数或运算符
GROUP BY 查询结果分组
[GROUP BY{col_name|position} [ASC|DESC],...]


HAVING 分组条件
[HAVING where_condition]
having 的条件必须保证为聚合函数或出现在语句当中

ORDER BY 对查询结果进行排序
[ORDER BY {col_name | expr | position} [ASC|DESC],...]

LIMIT 限制查询结果返回的数量
[LIMIT {[offset,]row_count|row_count OFFSET offset}]


网友评论