SQL SYNTAX
Reference:本文大部分是对w3c网站的教程的总结
- SQL SELECT
select Column
select *
- SQL SELECT DISTINCT
select distinct
select COUNT(distinct column_name)
- SQL WHERE
where clause
- SQL AND,OR AND NOT Operators
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
- SQL ORDER BY
ASC:ascending/
DESC:descending
order by
order by desc
order by several column
SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC;
- SQL INSERT INTO
INSERT INTO
If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query.
INSERT INTO table_name
VALUES (value1, value2, value3, ...)
Insert Data Only in Specified Columns
The following SQL statement will insert a new record, but only insert data in the “CustomerName”, “City”, and “Country” columns (CustomerID will be updated automatically):
INSERT INTO Customers (CustomerName, City, Country)
VALUES ('Cardinal', 'Stavanger', 'Norway');
- SQL NULL Values
We will have to use the IS NULL and IS NOT NULL operators instead.
S