MySql数据库随笔

1.什么是笛卡尔积

笛卡尔积是关系代数里的一个概念,表示两个表中的每一行数据任意组合。
结果:一表中每一行与另一表每一行的之间的所有组合(不重复) A表有:X行 B表有:Y行 结果 X*Y行;列为 X列+B列

2.SQL语句的执行顺序
SELECT Syntax 官方:​​​https://dev.mysql.com/doc/refman/5.7/en/select.html​​​
一条完整的不包含子查询和 UNION的sql查询语句

SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr ...]
[FROM table_references
[PARTITION partition_list]
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
[PROCEDURE procedure_name(argument_list)]
[INTO OUTFILE 'file_name'
[CHARACTER SET charset_name]
export_options
| INTO DUMPFILE 'file_name'

常见的SQL:

<SELECT clause> [<FROM clause>] [<WHERE clause>] [<GROUP BY clause>] [<HAVING clause>] [<ORDER BY clause>] [<LIMIT clause>]