官术网_书友最值得收藏!

  • MySQL 8 for Big Data
  • Shabbir Challawala Jaydip Lakhatariya Chintan Mehta Kandarp Patel
  • 197字
  • 2021-08-20 10:06:12

Select statement in MySQL 8

The Select statement is used to retrieve data from single or multiple tables:

SELECT field 1, field 2, field 3 from table_name [WHERE Clause] [GROUP BY {col_name }] [HAVING where_condition] [ORDER BY {col_name} {ASC | DESC}, ...] [LIMIT{OFFSET M}{LIMIT N}]

This is the common syntax used to retrieve data from a single table:

  • Fields one and two are the column names of the table. To fetch all columns from the table, the * expression can be used.
  • table_name indicates the table name from where data needs to be retrieved.
  • The WHERE clause can be used to specify any condition in a single and multiple column.
  • The Group BY function is used with aggregate functions to group the result sets.
  • The HAVING clause is needed after GROUP BY to filter based on conditions for a group of rows or aggregates. If we use the HAVING clause without GROUP BY, it would act similarly to the WHERE clause.
  • The ORDER BY clause is used to sort the table result sets in ascending or descending order.
  • LIMIT is used to constrain the number of rows returned by the SELECT statement.

Let's go through each clause.

主站蜘蛛池模板: 高安市| 墨竹工卡县| 定陶县| 焉耆| 乌兰浩特市| 获嘉县| 太仆寺旗| 嘉义市| 日土县| 察隅县| 盐城市| 东兰县| 惠来县| 余干县| 原平市| 务川| 邹城市| 修水县| 阳曲县| 墨竹工卡县| 荥阳市| 石渠县| 呼和浩特市| 鄱阳县| 河池市| 贵港市| 龙海市| 上蔡县| 阿克苏市| 丹东市| 宁阳县| 缙云县| 延安市| 博客| 东丰县| 政和县| 大连市| 怀宁县| 聊城市| 林州市| 崇仁县|