0% found this document useful (0 votes)
21 views

Learn SQL - Queries Cheatsheet - Codecademy

Uploaded by

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

Learn SQL - Queries Cheatsheet - Codecademy

Uploaded by

Loko Loko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
Cheatsheets / Learn SQL Queries AND Operator ‘The so operator allows multiple conditions to be combined. Records must match both conditions joined by sp to be included in the result set. The given uery will match any car that is blue and made after 2014, at are % Wildcard The x wildeard can be used in a Lxxe operator p to match zero or more unspecified character(s). The given query will match any movie that begins with the , followed by zero or more of any characters. AS Clause Columns or tables can be aiased using the as clause ‘This allows columns or tables to be specifically renamed In the returned result set. The given query will return a result set with the column for nae renamed to OR Operator The ot operator allows multiple conditions to be combined. Records matching either condition joined by the ox are included in the result set. The given query wil mers whose state is either ‘ca" or “Ww match cu SELECT Statement ‘The se.ecr + statement returns all columns from the provided table n the result set. The given query wil fetch all columns and records (rows) from the sovies. table, _ Wildcard The _ wildeard can be used ina Uke operator p to match any single unspecified character. The given query will match any movie which begins with a single character, followed by ove s FROM WHERE ECT AND year FROM WHERE SELECT FROM WHERE oR SELECT FROM *blue’ 2e14 LIKE "Thex" AS ‘movie title’ sens uy LIKE '_ove ORDER BY Clause The ofoek ey clause can be used to sort the result et by particular column elther alphabetically or numerically. It cean be ordered in two ways: is @ keyword used to sort the results in descending order. asc Isa keyword used to sort the results in ascending order (default LIKE Operator ‘The LiKe operator canbe used inside of a were clause to match a specified pattern. The given query will match any movie that begins with star inits title DISTINCT Clause Unique values of a column can be selected using @ DisTincr query. For a table contact detatis having ve rows in which the city column contains Chicago, Madison, Boston, Madison, and Denver, the given query would return: BETWEEN Operator ‘The setasen operator can be used to filter by a range of| values. The range of values can be text, numbers, or date. data. The given query will match any movie made between the years 1980 and 1990, inclusive. LIMIT Clause The Limrt clause is used to narrow, or limit, a result set to the specified number of rows. The given query will mit the result set to 5 rows. SELECT FROM ORDER BY Desc SELECT FROM WHERE LIKE ‘star%" SELECT DISTINCT FROM SELECT FROM WHERE year BETWEEN 198@ AND 1990 SELECT FROM LIMIT 5 NULL Values Column values can be wit , or have no value. These records can be matched (or not matched) using the 15 MLL and 15 nor suLt operators in combination with the iene clause. The given query will match all addresses where the address has a value or isnot wu WHERE Clause The west clause s used to fiter records (rows) that match a certain condition. The given query will select all records where the pub_year equals. 2017 SELECT FROM WHERE TS NOT NULL SELECT ROM WHERE 2017

You might also like