home blog portfolio Ian Fisher

SQL

A programming language used to interact with relational databases. Its verbose, pseudo-English syntax (SELECT * FROM my_table WHERE my_column IS NOT NULL) is a relic from the COBOL era of computer programming. Every database system has its own dialect.

Cheatsheet

Find rows with duplicate values of column

SELECT t.* FROM my_table t
JOIN (
  SELECT my_col FROM my_table GROUP BY my_col HAVING COUNT(*) > 1
) dup ON t.my_col = dup.my_col
ORDER BY my_col

Posts