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

  • 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.

主站蜘蛛池模板: 遂平县| 惠水县| 遂平县| 泗洪县| 文成县| 从江县| 游戏| 北流市| 顺平县| 沅陵县| 新和县| 太和县| 高唐县| 东兴市| 宣威市| 克拉玛依市| 镇巴县| 阿巴嘎旗| 万载县| 合江县| 洱源县| 屏东市| 织金县| 阿坝县| 嘉鱼县| 永顺县| 宁远县| 策勒县| 孝感市| 乐陵市| 花莲县| 仙居县| 锡林浩特市| 东港市| 稷山县| 桐梓县| 山东省| 沙河市| 梧州市| 莎车县| 温州市|