SELECT DISTINCT col_name(s) FROM table_name WHERE col_name = ' abc ' AND (col_name = 'abc' OR col_name = 'abc') OR col_name LIKE '%xyz%' ORDER BY col1_name ASC, col2_name DESC
SELECT col_name(s) FROM tb_name WHERE col_name IN (value1, value2,...)
| Operator || Description |
| = || Equal |
| <> || Not equal |
| > || Greater than |
| < || Less than |
| >= || Greater than or equal |
| <= || Less than or equal |
| BETWEEN || Between an inclusive range |
| LIKE || |
Search for a pattern
e.g. SELECT * FROM Persons
WHERE LastName IN ('Hansen','Pettersen')
The following syntax is weird, according to different database system.SELECT col_name(s) FROM tb_name WHERE col_name BETWEEN value1 AND value2, select data when col_name = value1?
SELECT col_name(s) FROM tb_name WHERE col_name NOT BETWEEN value1 AND value2, select data when col_name = value2?
UPDATE tb_name SET col_name(s) WHERE col_name = 'abc'
SELECT col_names AS col_alias_names FROM tb_name;
SELECT col_names FROM tb_name AS tb_alias_name;
e.g. SELECT LastName AS Family, FirstName AS Name
FROM Persons AS Employees;
Tables in a database can be related to each other with keys, which means every table must have a primary key. A primary key is a column or combined columns with a unique value for each row.
SELECT field1, field2, field3
INNER JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield