博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL之SELECT
阅读量:5831 次
发布时间:2019-06-18

本文共 2519 字,大约阅读时间需要 8 分钟。

下面是连接MySQL后,获取的SELECT 语句的帮助:

mysql> HELP SELECTName: 'SELECTDescription://描述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    [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]]SELECT is used to retrieve rows selected from one or more tables, andcan include UNION statements and subqueries. See [HELP UNION], andhttp://dev.mysql.com/doc/refman/5.5/en/subqueries.html.The most commonly used clauses of SELECT statements are these:o Each select_expr indicates a column that you want to retrieve. There  must be at least one select_expr.o table_references indicates the table or tables from which to retrieve  rows. Its syntax is described in [HELP JOIN].o The WHERE clause, if given, indicates the condition or conditions  that rows must satisfy to be selected. where_condition is an  expression that evaluates to true for each row to be selected. The  statement selects all rows if there is no WHERE clause.  In the WHERE expression, you can use any of the functions and  operators that MySQL supports, except for aggregate (summary)  functions. See  http://dev.mysql.com/doc/refman/5.5/en/expressions.html, and  http://dev.mysql.com/doc/refman/5.5/en/functions.html.SELECT can also be used to retrieve rows computed without reference toany table.URL: http://dev.mysql.com/doc/refman/5.5/en/select.html

接下来我们一起看一下,SELECT 语句的一些参数和用法:

SELECT ->本意: 即为 选择、挑选;

[ALL | DISTINCT | DISTINCTROW ]

All:所有(默认);

DISTINCT:独特的,显示不同的;
DISTINCTROW:显示不同的行;
mysql> SELECT [DISTINCT/DISTINCTROW] column_name FROM table_name;
ALL参数为默认的参数,而DISTINCT/DISTINCTROW为可选的参数,上面的语句执行后,即可显示table_name表的column_name 中不同的元素,如果把column_name 改成 * 即为选择全部,而再加上,这些参数,意思即为选择不一样的行,而且在这里DISTINCT/DISTINCTROW没有区别。

[HIGH_PRIORITY]  [STRAIGHT_JOIN]  [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]  [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]

转载于:https://blog.51cto.com/13845370/2134472

你可能感兴趣的文章
Linux-网络连接-(VMware与CentOS)
查看>>
寻找链表相交节点
查看>>
AS3——禁止swf缩放
查看>>
linq 学习笔记之 Linq基本子句
查看>>
[Js]布局转换
查看>>
Hot Bath
查看>>
国内常用NTP服务器地址及
查看>>
Java annotation 自定义注释@interface的用法
查看>>
Apache Spark 章节1
查看>>
phpcms与discuz的ucenter整合
查看>>
Linux crontab定时执行任务
查看>>
mysql root密码重置
查看>>
33蛇形填数
查看>>
选择排序
查看>>
SQL Server 数据库的数据和日志空间信息
查看>>
前端基础之JavaScript
查看>>
自己动手做个智能小车(6)
查看>>
自己遇到的,曾未知道的知识点
查看>>
P1382 楼房 set用法小结
查看>>
分类器性能度量
查看>>