Skip to main

What is SQL? #

SQL stands for Structured Query Language. Query means the same as it does in normal English-to make a request or ask a question. So SQL is a programming language used to get information from a database.

It follows this kind of a structure:

DO SOMETHING from thisFile
CommandDescription
SELECT *selects all columns
SELECT dogselects the column dog
FROM petsfrom the column cats
SELECT cats, dogsgets both the dogs and cats column
SELECT jumpMan AS Jumper from Fitnessrenames the column jumpMan to Jumper
SELECT DISTINCT year_hired FROM employeesselects unique year_hired so no repeating years appear
CREATE VIEW view_name AS SELECT column1, column2, …FROM table_nameSaves SQL table so you can reuse it later on in the SQL file

SQL Logic Operators #

Logic Operators lets you refine what you want to extract from a table.

CommandDescription
ALLTrue if all are true
ANDTrue if A and B are true
ANYTrue if any statement is true
BETWEENTrue if argument exists within range
EXISTSTrue if argument exists within rows
INTrue if value is equal to a value in a list
LIKETrue if argument matches a pattern
NOTReverses the result of boolean operator
ORTrue if either argument is true
SOMETrue if some of the argument is true