SQL Notes
JOIN vs. RIGHT JOIN vs. LEFT JOIN
Extracted from this source
-
(INNER) JOIN: Returns records that have matching values in both tables
-
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
-
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
-
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
HAVING vs. WHERE
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
WHERE
: Like if afterSELECT xx FROM yy
HAVING
: Only after everyGROUP BY
, it’s likeWHERE
but for aggregate functions.
###
IS vs =
IS is for alphanumeric values and = is for numbers
test
|name|value|
|pepe| 11 |
|pepa| 5 |
|peepo| 11|
SELECT name FROM test
WHERE name IS "pep%"
>> pepe,pepa
SELECT name FROM test
WHERE value = 11
>> pepe, peepo
Date: March 20, 2022