In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how mysql queries the data of a certain field in the database. I hope you will gain a lot after reading this article. Let's discuss it together.
Mysql's method of querying a field in a database: through the SELECT statement, using "SELECT"
< 字段名 >FROM
< 数据表名 >; "Syntax to query; if you want to query multiple fields, separate the different field names with a comma".
In MySQL, you can use SELECT statements to query data. Query data refers to the use of different query methods to obtain different data from the database according to the requirements, which is the most frequent and important operation.
The syntax format of SELECT is as follows:
SELECT {* |} [FROM, … [WHERE [GROUP BY [HAVING [{} …]] [ORDER BY] [LIMIT [,]
Among them, the meaning of each clause is as follows:
{* |} contains a list of fields with asterisk wildcards, indicating the name of the field to be queried.
,... Tables 1 and 2 represent the sources of query data, which can be single or multiple
WHERE is optional, and if selected, the query data must meet the query criteria.
GROUP BY
< 字段 >That tells MySQL how to display the queried data and group it by the specified field
[ORDER BY
< 字段 >This clause tells MySQL in what order the queried data is displayed, which can be sorted in ascending (ASC) and descending (DESC) order, which is ascending by default.
[LIMIT [,]], this clause tells MySQL to display the number of pieces of data that are queried each time.
Query the fields specified in the table
The syntax format for a field in the query table is:
SELECT
< 字段名 >FROM
< 表名 >Example 3
Query the names of all the students in the name column in the tb_students_info table, and the SQL statement and run results are shown below.
Mysql > SELECT name FROM tb_students_info;+-+ | name | +-+ | Dany | | Green | | Henry | | Jane | | Jim | | John | | Lily | | Susan | | Thomas | | Tom | +-+ 10 rows in set (0.00 sec)
The output shows all the data under the name field in the tb_students_info table.
You can use the SELECT declaration to obtain the data under multiple fields. You only need to specify the field name to be looked up after the keyword SELECT. Different field names are separated by commas "and". There is no need to add a comma after the last field. The syntax format is as follows:
SELECT,... , FROM
Example 4
Get the id, name, and height columns from the tb_students_info table, and the SQL statement and run results are shown below.
Mysql > SELECT id,name,height-> FROM tb_students_info + -. | 178 | 10 | Tom | 165 | +-+ 10 rows in set (0.00 sec)
The output shows all the data under the id, name, and height fields in the tb_students_info table.
After reading this article, I believe you have a certain understanding of how mysql queries the data of a certain field in the database. You want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 235
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.