
SQL Cheatsheet
Here's a cheat sheet to quickly review all SQL queries before an interview. TABLE Queries CREATE TABLE table_name (column1 datatype, column2 datatype, ... ); DROP TABLE table_name; ALTER TABLE table_name ADD column_name datatype; INSERT INTO table_name (column1, column2) VALUES (value_or_expr1, value_or_expr2); SELECT Queries SELECT * FROM table_name; SELECT DISTINCT column_name1, column_name2 FROM table_name; SELECT column_name1 FROM table_name ORDER BY column_name2 ASC / DESC; /* (by default it is ascending if you don't write DESC) */ SELECT column_name1 FROM table_name WHERE column_name2 BETWEEN x AND y; SELECT column_name1 FROM table_name WHERE column_name2 NOT BETWEEN x AND y; SELECT column_name1 FROM table_name WHERE column_name1 LIKE "%XYZ%"; SELECT column_name1 FROM table_name WHERE column_name1 NOT LIKE "%XYZ%"; SELECT column_name FROM table_name ORDER BY column_name1 LIMIT number_of_rows OFFSET num_offset; /* The LIMIT will reduce the number of rows to return, and the optiona
Continue reading on Dev.to
Opens in a new tab




