SQL语法介绍
Posted 个人博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL语法介绍相关的知识,希望对你有一定的参考价值。
一、Select 查询
语法:
mysql> help select
Name: ‘SELECT‘
Description:
Syntax:
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‘
| INTO var_name [, var_name]]
[FOR UPDATE | LOCK IN SHARE MODE]]
1、Limit
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
mysql> select * from employees order by emp_no limit 50,5; (从50条,向后偏移5个)
+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date |
+--------+------------+------------+-----------+--------+------------+
| 10051 | 1953-07-28 | Hidefumi | Caine | M | 1992-10-15 |
| 10052 | 1961-02-26 | Heping | Nitsch | M | 1988-05-21 |
| 10053 | 1954-09-13 | Sanjiv | Zschoche | F | 1986-02-04 |
| 10054 | 1957-04-04 | Mayumi | Schueller | M | 1995-03-13 |
| 10055 | 1956-06-06 | Georgy | Dredge | M | 1992-04-27 |
+--------+------------+------------+-----------+--------+------------+
5 rows in set (0.00 sec)
以上是关于SQL语法介绍的主要内容,如果未能解决你的问题,请参考以下文章