- 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.
推薦閱讀
- Node.js+Webpack開發(fā)實(shí)戰(zhàn)
- AngularJS Testing Cookbook
- Python量化投資指南:基礎(chǔ)、數(shù)據(jù)與實(shí)戰(zhàn)
- C# Programming Cookbook
- JMeter 性能測(cè)試實(shí)戰(zhàn)(第2版)
- 神經(jīng)網(wǎng)絡(luò)編程實(shí)戰(zhàn):Java語言實(shí)現(xiàn)(原書第2版)
- Django Design Patterns and Best Practices
- 深入淺出Android Jetpack
- 零基礎(chǔ)學(xué)Java程序設(shè)計(jì)
- Mastering Python Networking
- QGIS:Becoming a GIS Power User
- 深入淺出RxJS
- Cybersecurity Attacks:Red Team Strategies
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)教程(Windows 7+Office 2010)
- 平面設(shè)計(jì)經(jīng)典案例教程:CorelDRAW X6