5/22/25, 6:38 PM about:blank
SQL Cheat Sheet: Basics
Command Syntax Description Example
SELECT column1, column2, ... FROM SELECT statement is used to fetch data
SELECT SELECT city FROM placeofinterest;
table_name; from a database.
SELECT column1, column2, ...FROM WHERE clause is used to extract only those
WHERE SELECT * FROM placeofinterest WHERE city = 'Rome' ;
table_name WHERE condition; records that fulfill a specified condition.
COUNT is a function that takes the name of
a column as argument and counts the SELECT COUNT(country) FROM placeofinterest WHERE
COUNT SELECT COUNT * FROM table_name ;
number of rows when the column is not country='Canada';
NULL.
DISTINCT function is used to specify that
SELECT DISTINCT columnname FROM SELECT DISTINCT country FROM placeofinterest WHERE
DISTINCT table_name;
the statement is a query which returns type='historical';
unique values in specified columns.
is a clause to specify the maximum
LIMIT SELECT * FROM placeofinterest WHERE
LIMIT SELECT * FROM table_name LIMIT number;
number of rows the result set must have. airport="pearson" LIMIT 5;
INSERT INTO table_name INSERT is used to insert new rows in the INSERT INTO placeofinterest
INSERT (column1,column2,column3...) (name,type,city,country,airport) VALUES('Niagara
VALUES(value1,value2,value3...); table. Waterfalls','Nature','Toronto','Canada','Pearson');
UPDATE table_name SET[[column1]=[VALUES]] UPDATE used to update the rows in the UPDATE placeofinterest SET name = 'Niagara Falls'
UPDATE WHERE [condition]; table. WHERE name = "Niagara Waterfalls";
DELETE statement is used to remove rows
DELETE FROM placeofinterest WHERE city IN
DELETE DELETE FROM table_name WHERE [condition]; from the table which are specified in the ('Rome','Vienna');
WHERE condition.
Author(s)
Malika Singla
about:blank 1/1