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

Cheatsheet 5

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)
11 views1 page

Cheatsheet 5

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

03/09/2024 13:31 about:blank

SQL Cheat Sheet: Basics

Command Syntax Description Example


SELECT column1, column2, ... FROM SELECT statement is used to fetch data from
SELECT SELECT city FROM placeofinterest;
table_name; a database.
SELECT column1, column2, ...FROM WHERE clause is used to extract only 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 and counts the number SELECT
COUNT(country) FROM placeofinterest WHERE
COUNT SELECT COUNT * FROM table_name ;
country='Canada';
of rows when the column is not 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.
LIMIT is a clause to specify the maximum 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 placeofinterest SET name = 'Niagara Falls'
UPDATE WHERE [condition];
UPDATE used to update the rows in the 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