0% found this document useful (0 votes)
2 views1 page

Module 1

This document is a SQL cheat sheet that outlines basic SQL commands and their syntax. It includes examples for commands such as SELECT, WHERE, COUNT, DISTINCT, LIMIT, INSERT, UPDATE, and DELETE. The cheat sheet serves as a quick reference for fetching, inserting, updating, and deleting data in a database.

Uploaded by

dowanan742
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)
2 views1 page

Module 1

This document is a SQL cheat sheet that outlines basic SQL commands and their syntax. It includes examples for commands such as SELECT, WHERE, COUNT, DISTINCT, LIMIT, INSERT, UPDATE, and DELETE. The cheat sheet serves as a quick reference for fetching, inserting, updating, and deleting data in a database.

Uploaded by

dowanan742
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/ 1

4/10/25, 2:51 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

You might also like