Home >Database >Mysql Tutorial >How to query the value of a certain field in mysql
In mysql, you can use the SELECT statement with the specified field name to query the value of a field. The syntax is "SELECT field name FROM table name WHERE clause LIMIT clause;".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the SELECT statement with the specified field name to query the value of a field.
The syntax format of a field in the query table is:
SELECT 列名 FROM 表名 [WHERE <表达式> [GROUP BY <group by definition> [HAVING <expression> [{<operator> <expression>}…]] [ORDER BY <order by definition>] [LIMIT[<offset>,] <row count>] ]
WHERE 41256fb142f22f4bfc3f76fe922f5535 is optional. If this item is selected, the query will be limited. The data must satisfy the query conditions.
GROUP BY3b26370eed070b4e2af74808aa8f2dee, this clause tells MySQL how to display the queried data and group it according to the specified field.
[ORDER BY0f5333100010744a1571ca8552350494], this clause tells MySQL in what order to display the queried data. The possible sorting is ascending order (ASC) and descending order (DESC ), which is ascending by default.
Example 1:
Query the names of all students in the name column of the tb_students_info table. The SQL statement and running results are as follows.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 data under the name field in the tb_students_info table. Use the SELECT statement to obtain data under multiple fields. You only need to specify the field name to be searched after the keyword SELECT. Different field names are separated by commas "," after the last field. There is no need to add commas. The syntax format is as follows:
SELECT <字段名1>,<字段名2>,…,<字段名n> FROM <表名>;
Example 2:
Get the three columns of id, name and height from the tb_students_info table. The SQL statement and running results are as follows shown.mysql> SELECT id,name,height -> FROM tb_students_info; +----+--------+--------+ | id | name | height | +----+--------+--------+ | 1 | Dany | 160 | | 2 | Green | 158 | | 3 | Henry | 185 | | 4 | Jane | 162 | | 5 | Jim | 175 | | 6 | John | 172 | | 7 | Lily | 165 | | 8 | Susan | 170 | | 9 | Thomas | 178 | | 10 | Tom | 165 | +----+--------+--------+ 10 rows in set (0.00 sec)The output shows all data under the three fields of id, name and height in the tb_students_info table. [Related recommendations:
mysql video tutorial]
The above is the detailed content of How to query the value of a certain field in mysql. For more information, please follow other related articles on the PHP Chinese website!