The command keyword for querying data in SQL is SELECT, which is used to extract specific columns or records from a database table. The SELECT statement structure includes: SELECT [DISTINCT]
FROM [WHERE
][ORDER BY ][LIMIT ] Keywords for query commands in SQL: SELECT
Keywords for querying data in SQL The words are SELECT. It is used to extract specific columns or records from database tables.
SELECT statement structure:
<code class="sql">SELECT [DISTINCT] <要提取的列名> FROM <表名> [WHERE <过滤条件>] [ORDER BY <排序列>] [LIMIT <返回记录数>]</code>SELECT statement elements:
- DISTINCT: Used to exclude duplicate records.
- Column name to extract: Specify the column to be obtained from the table.
- FROM: Specify the table to query.
- WHERE: Specify filter conditions to filter out records that meet specific conditions.
- ORDER BY: Specify the column by which the results will be sorted.
- LIMIT: Specify the number of records to return.
Example:
The following statement queries the names and email addresses of all customers from the
Customers
table:<code class="sql">SELECT Name, Email FROM Customers;</code>The following statement queries the product names and prices with a price greater than 100 from the
Products
table:<code class="sql">SELECT Name, Price FROM Products WHERE Price > 100;</code>The following statement queries all orders in the past 30 days from the
Orders
table , and sorted by date in descending order:<code class="sql">SELECT * FROM Orders WHERE OrderDate >= DATE('now', '-30 days') ORDER BY OrderDate DESC;</code>The above is the detailed content of The keywords of query commands in sql are. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cnPrevious article:What is the command that expresses query in sqlNext article:What is the command that expresses query in sql