The basic query statement of MySQL is SELECT, which is used to retrieve data from a database table. The SELECT syntax includes: SELECT [distinct] column name 1, column name 2, ...FROM table name WHERE condition HAVING grouping condition [LIMIT limit the number of rows].
The basic statement of MySQL query
The basic statement of MySQL query isSELECT
, use Used to retrieve data in selected databases and tables. The syntax format is as follows:
<code>SELECT [distinct] 列名1, 列名2, ... FROM 表名 [WHERE 条件] [GROUP BY 分组列] [HAVING 分组条件] [ORDER BY 排序列] [LIMIT 限制行数]</code>
Among them:
SELECT
: Specify the column to be retrieved. DISTINCT
(optional): Eliminate duplicate rows. Table name
: Specify the table to retrieve data from. WHERE
: Specify filter conditions and retrieve only rows that meet the conditions. GROUP BY
: Group the rows in the result set. HAVING
: Specify the filtering conditions for grouping. ORDER BY
: Specifies to sort the rows in the result set. LIMIT
: Limit the number of rows returned in the result set. Example:
<code>SELECT name, age FROM students WHERE age > 18;</code>
This query will retrieve the names and ages of all students who are older than 18 years old from the students
table.
The above is the detailed content of What are the basic statements of mysql query. For more information, please follow other related articles on the PHP Chinese website!