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