Querying from multiple tables
Inner join t1 and t2
SELECT c1, c2
FROM t1
INNER JOIN t2 ON condition
Left join t1 and t1
SELECT c1, c2
FROM t1
LEFT JOIN t2 ON condition
Right join t1 and t2
SELECT c1, c2
FROM t1
RIGHT JOIN t2 ON condition
Perform full outer join
SELECT c1, c2
FROM t1
FULL OUTER JOIN t2 ON condition
Produce a Cartesian product of rows in tables
SELECT c1, c2
FROM t1
CROSS JOIN t2
Another way to perform cross join
SELECT c1, c2
FROM t1, t2
Join t1 to itself using INNER JOIN clause
SELECT c1, c2
FROM t1 A
INNER JOIN t1 B ON condition
Using SQL Operators Combine rows from two queries
SELECT c1, c2 FROM t1
UNION [ALL]
SELECT c1, c2 FROM t2
Return the intersection of two queries
SELECT c1, c2 FROM t1
INTERSECT
SELECT c1, c2 FROM t2
Subtract a result set from another result set
SELECT c1, c2 FROM t1
MINUS
SELECT c1, c2 FROM t2
Query rows using pattern matching %, _
SELECT c1, c2 FROM t1
WHERE c1 [NOT] LIKE pattern
Query rows in a list
SELECT c1, c2 FROM t
WHERE c1 [NOT] IN value_list
Query rows between two values
SELECT c1, c2 FROM t
WHERE c1 BETWEEN low AND high
Check if values in a table is NULL or not
SELECT c1, c2 FROM t
WHERE c1 IS [NOT] NULL
Comments