Home

Awesome

Learning SQL

Just one of the things I'm learning. https://github.com/hchiam/learning

Older tutorials

Node.js MySQL tutorial

Miscellaneous notes

Here's an alternative diagram to using venn diagrams to understand SQL joins: https://www.reddit.com/r/SQL/comments/1bv88ht/please_use_these_instead_of_those_abominable_venn/

UDF (user-defined function):

temporary UDF:

CREATE TEMP FUNCTION AddFourAndDivideTemporary(x INT64, y INT64)
RETURNS FLOAT64
AS (
  (x + 4) / y
);

SELECT
  val, AddFourAndDivideTemporary(val, 2)
FROM
  UNNEST([2,3,5,8]) AS val;

persistent UDF: (requires a dataset like "mydataset." specified for the function)

CREATE FUNCTION mydataset.AddFourAndDividePersistent(x INT64, y INT64)
RETURNS FLOAT64
AS (
  (x + 4) / y
);

SELECT
  val, mydataset.AddFourAndDividePersistent(val, 2)
FROM
  UNNEST([2,3,5,8,12]) AS val;

https://dba.stackexchange.com/questions/283022/what-does-the-go-statement-do-in-sql-server

https://www.w3schools.com/sql/sql_delete.asp