Logo

Codcups

Complete SQL Reference's

Intro Of SQL

SQL (pronounced "ess-cue-ell" or sometimes "sequel") stands for Structured Query Language. It is the standard language used to communicate with relational databases — databases that store data in tables with rows and columns.

📘 SQL Keywords
SELECTUsed to select data from a database
FROMSpecifies the table to select or delete data from
WHEREFilters records
INSERT INTOAdds new data into a table
VALUESProvides values for an INSERT
UPDATEModifies existing data
SETDefines new values in UPDATE
DELETEDeletes data from a table
CREATE TABLECreates a new table
ALTER TABLEModifies a table structure
DROP TABLEDeletes a table
JOINCombines rows from multiple tables
INNER JOINReturns rows with matching values
LEFT JOINAll rows from left + matched from right
RIGHT JOINAll rows from right + matched from left
FULL JOINAll rows from both tables
GROUP BYGroups rows sharing a property
ORDER BYSorts results
HAVINGFilters grouped records
ASAlias for a column or table
DISTINCTReturns only distinct values
LIMITSpecifies number of records to return
OFFSETSkips number of records
INMatches any in a list
NOT INExcludes from list
LIKEPattern matching
IS NULLChecks for NULL
UNIONCombines multiple SELECT results
CASEConditional logic

📦 SQL Data Types
INTInteger (whole number)
FLOAT / DOUBLEFloating point numbers
DECIMAL(p,s)Exact numeric value with precision
CHAR(n)Fixed-length character
VARCHAR(n)Variable-length character
TEXTLarge text
DATEYYYY-MM-DD format
TIMEHH:MM:SS format
DATETIMEDate and time
BOOLEANTRUE/FALSE values

📌 SQL Constraints
PRIMARY KEYUniquely identifies a row
FOREIGN KEYLinks to another table's primary key
UNIQUEEnsures unique values
NOT NULLValue cannot be null
DEFAULTSets a default value
CHECKEnsures condition is true
AUTO_INCREMENTAuto-increments numeric field

⚙️ SQL Functions
COUNT()Returns number of rows
SUM()Returns the total sum
AVG()Returns the average
MIN()Returns the minimum value
MAX()Returns the maximum value
NOW()Returns current datetime
UPPER()Converts to uppercase
LOWER()Converts to lowercase
ROUND()Rounds a number
LEN() / LENGTH()Length of a string
SUBSTRING()Extract part of string

Click to go back on notes page.