SELECT DISTINCT statement <br /> in the table may contain duplicate values. This is not a problem, but sometimes you may want to just list different (distinct) values.
Keywords DISTINCT only difference for the return value.
Syntax: SELECT DISTINCT name FROM table name column
<br /> For WHERE clause to conditionally select data from the table can be added to the SELECT statement WHERE clause.
Syntax: SELECT column names FROM table name WHERE column operator value of the following operators can be used in the WHERE clause:
Operator Description
= Equal to
<> Is not equal to
> Greater than
<Less than
> = Greater than or equal
<= Less than or equal
BETWEEN within a certain range
LIKE search for a pattern Note: In some versions of SQL, operator <> can be written as! =
AND and OR operators
WHERE AND and OR sub-statement in the combination of two or more conditions. If the first condition and second conditions are true, then the AND operator displays a record. If the first condition and second condition as long as there is a set up, the OR operator displays a record.
ORDER BY statement
ORDER BY statement is used according to the specified column to sort the result set. ORDER BY statement, the default sort in ascending order on the record. If you want to sort the records in descending, you can use the DESC keyword; ascending order with the ASC.
INSERT INTO statement
INSERT INTO statement is used to insert a new row in the table.
Grammar
INSERT INTO table name VALUES (value 1, value 2 ,....)
We can also specify the column to insert the data:
INSERT INTO table_name (column 1, column 2 ,...) VALUES (value 1, value 2 ,....)
Update statement
Update statement to modify data in the table.
Syntax: UPDATE table name SET column column name = new value WHERE name = a value such as: UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing' WHERE LastName = 'Wilson'
DELETE statement
DELETE statement is used to delete a table row.
Syntax: DELETE FROM table WHERE name = value column name
LIMIT statement
LIMIT statement is used to control the output of the Number of data syntax: SELECT * FROM table name WHERE name = a value of LIMIT column value
LIKE operator
LIKE operator in the WHERE clause for the column specified in the search mode.
Syntax: SELECT * FROM table WHERE name LIKE pattern column name wildcard: "%" means any length of characters, "_" represents a character, [charlist] that character out of any single character, [^ charlist] or [ ! charlist] characters that are not listed in any single character
IN operator
IN operator in the WHERE clause allows us to provision multiple values.
Syntax: SELECT * FROM table name WHERE column name IN (value1, value2 ,...)
If (value1, value2 ,...) is character, then, must be accompanied by single quotation marks
BETWEEN operator <br /> BETWEEN ... AND operator will be selected between the range of data between two values. These values can be numeric, text or date.
Syntax:
SELECT column_name (s) FROM table_name WHERE column_name BETWEEN value1 AND value2
For use outside the scope of the above examples show, please use the NOT operator
SELECT column_name (s) FROM table_name WHERE column_name NOT BETWEEN value1 AND value2
As examples: using table name aliases assume we have two tables are: "Persons" and "Product_Orders". We were their designated alias "p" and "po".
Now we want to list "John Adams" to all orders.
We can use the following SELECT statement:
SELECT po.OrderID, p.LastName, p.FirstName FROM Persons AS p, Product_Orders AS po WHERE p.LastName = 'Adams'AND p.FirstName =' John '