0% found this document useful (0 votes)
95 views2 pages

SQL Cheat Sheet - Basics - SELECT, INSERT, UPDATE, DELETE, COUNT, DISTINCT, LIMIT

The document provides a SQL cheat sheet that defines common SQL commands like SELECT, WHERE, COUNT, DISTINCT, LIMIT, INSERT, UPDATE, and DELETE. It explains the syntax and usage of each command and provides simple examples to illustrate how each command is used.

Uploaded by

titanium om
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views2 pages

SQL Cheat Sheet - Basics - SELECT, INSERT, UPDATE, DELETE, COUNT, DISTINCT, LIMIT

The document provides a SQL cheat sheet that defines common SQL commands like SELECT, WHERE, COUNT, DISTINCT, LIMIT, INSERT, UPDATE, and DELETE. It explains the syntax and usage of each command and provides simple examples to illustrate how each command is used.

Uploaded by

titanium om
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

6/21/23, 3:35 PM about:blank

SQL Cheat Sheet: Basics

Command Syntax Description Example


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 those SELECT * FROM placeofinterest WHERE city == 'Rome'
WHERE table_name WHERE condition; ;
records that
fulfill a
specified
condition.
COUNT is a
function
that takes
the name of
a column as
argument SELECT COUNT(country) FROM placeofinterest WHERE
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
DISTINCT SELECT DISTINCT columnname FROM a query
table_name;
SELECT DISTINCT country FROM placeofinterest WHERE
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

about:blank 1/2
6/21/23, 3:35 PM about:blank

rows the
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) VALUES('Niagara
VALUES(value1,value2,value3...); rows in the Waterfalls','Nature','Toronto','Canada','Pearson');
table.
UPDATE used
UPDATE table_name SET[[column1]= to update UPDATE placeofinterest SET name = 'Niagara Falls'
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 IN
DELETE [condition]; ('Rome','Vienna');
which are
specified in
the
WHERE
condition.

Author(s)
Malika Singla

Changelog
Date Version Changed by Change Description
2023-05-04 1.1 Benny Formatting changes
2021-07-27 1.0 Malika Initial Version

about:blank 2/2

You might also like