Queries column
- 1-1 The basic syntax of the SELECT statement
SELECT <column name>, ...
FROM <表名>;
- 1-2 grammar check out all of the columns in the table
SELECT *
FROM <表名>;
An asterisk (*) are representative of all of the columns mean. Use the asterisk display order of the columns can not be set.
- Syntax 1-3
1. The column set aliases
eg:SELECT product_id AS id,
product_name AS name,
FROM Product;
Aliases are Chinese, Chinese needed when using double quotation marks ( "") enclosed.
2. The constant query
SELECT clause can not only write the column names, you can also write constants. When using a constant string or date in the SQL statement, you must use single quotation marks ( ') to enclose it.
eg:SELECT '商品' AS string ,38 AS number, ’2009-02-24' AS date, product_id,product_name
FROM Product;
Results of the
- Syntax 1-4 delete duplicate rows from the results
SELECT DISTINCT product_type
FROM Product;
*: When using DISTINCT, NULL is also considered a type of data. NULL when present in a plurality of rows, will be merged into a NULL data.
Prior to use multiple columns DISTINCT, a plurality of columns of data will be combined, the repeated data combined into one.
- Syntax 1-5 to select records based on a WHERE clause
SELECT <column name>, ...
FROM <表名>
WHERE <conditional expression>;
- 1-6 conditional expression syntax
1. Comparison Operators
eg:SELECT product_name,product_type
FROM Product
WHERE sale_price = 500;
2. designed to determined whether the IS NULL NULL operator
Select the null record
WHERE purchase_price IS NULL;
Wants to record selected is not NULL
WHERE purchase_price IS NOT NULL;