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

This is website

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 after SELECT xx FROM yy
  • HAVING: Only after every GROUP BY, it’s like WHERE 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
 Tags:  coding SQL

Previous
Task 1 - Google CTF Beginners Quest 2021

Next
Kadane's Algorithm & LeetCode 53 Maximum Subarray