In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces mysql how to query field values, the article is very detailed, has a certain reference value, interested friends must read it!
Mysql query field value method: 1, use the "SELECT * FROM table name;" statement, you can list the values of all fields in the specified data table; 2, use the "SELECT field name FROM table name;" statement, you can list the values of the specified fields in the specified data table.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
The method of querying Field value (data) by mysql
1. Query all the field data in the table
Syntax:
SELECT * FROM table name
Example:
Query data for all fields from the tb_students_info table
Mysql > use test_db;Database changedmysql > SELECT * FROM tb_students_info +-+ | id | name | dept_id | age | sex | height | login_date | + -+-+ | 1 | Dany | 1 | 25 | F | 2015 | 09-10 | 2 | Green | 3 | 23 | F | 2016-10-22 | 3 | Henry | 2 | 23 | M | 2015-05-31 | 4 | Jane | 1 | 22 | F | 2016-12-20 | 5 | | Jim | 1 | 24 | M | 2016 | 01-15 | | 6 | John | 2 | 21 | M | 2015 | 11-11 | | 7 | Lily | 6 | 22 | F | 2016-02-26 | 8 | Susan | 4 | 23 | F | 2015-10-01 | 9 | Thomas | 3 | 22 | M | 2016-06-07 | | | 10 | Tom | 4 | 23 | M | 165,165 | 2016-08-05 | +-+ 10 rows in set (0.26sec) |
The result shows that when you use the "*" wildcard, all columns are returned, and the data columns are displayed in the order in which the table was created.
Note: in general, it is best not to use the wildcard "*" unless you need to use all the field data in the table. Although using wildcards can save time entering query statements, getting unwanted column data usually reduces the efficiency of the query and the application used. The advantage of using "*" is that when you don't know the names of the columns you want, you can get them through "*".
2. Query the field data specified in the table
Syntax:
SELECT column name FROM table name
Example:
Query the names of all students in the name column in the tb_students_info table
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.
Note: data under multiple fields can be obtained by using SELECT declaration. You only need to specify the field name to be found 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; this is all the content of the article "how to query field values for mysql". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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: 0
*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.