Section 1

Preview this deck

Logical operators

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (17)

Section 1

(17 cards)

Logical operators

Front

A logical operator returns the value True if the condition being evaluated is met. Otherwise, the value returned is False. AND: budget > 1000000 AND gross > 1000000 OR: budget > 1000000 OR gross > 1000000 BETWEEN... AND: title_year BETWEEN 2010 AND 2012 AS year_range IN: title_year IN (2010, 2012, 2014) AS year_range, IS NULL: gross IS NULL AS gross_is_null The NOT operator is a negate operator. It reverts the meaning of the logical operator with which it is being used.

Back

USE movies_db

Front

Select a database

Back

What can SQL do?

Front

SQL can handle the following data tasks with ease: - Add data - Extract data - Modify data - Delete data

Back

SHOW DATABASES;

Front

show databases

Back

CONCAT( <col_1> , <col_2>) <col_1> + <col_2>

Front

Concatenate

Back

LTRIM() RTRIM() TRIM()

Front

return the string with spaces removed.

Back

SELECT Multiple Columns

Front

Multiple column selects in SQL are separated by commas.

Back

Arithmetic operators

Front

SELECT <column name> / 1000000 AS 'col name', <column name> - <column name> FROM <table name>;

Back

SELECT <column name> FROM <table name>;

Front

SELECT indicates which column FROM indicates which tables

Back

Commenting your code

Front

-- Syntax for single line comments /* Syntax for multi line comments */

Back

Renaming New Columns: Aliasing

Front

A few tips when creating aliases: Alias should be informative but still concise. When a name has two parts, separate with the underscore character _ , not spaces. Avoid aliases that are reserved keywords in SQL. Avoid delimiters in the alias.

Back

Comparison operators

Front

A comparison operator is a mathematical symbol used to evaluate between two values. The resulting value created by a comparison operator is either True or False. (1s & 0s)

Back

CASE... WHEN...

Front

CASE WHEN statements are SQL's version of an IF-THEN-ELSE statements. ex: SELECT movie_title, CASE WHEN title_year > 2014 THEN 'new' WHEN title_year BETWEEN 2012 AND 2014 THEN 'new-ish' ELSE 'old' END AS movie_age FROM movies;

Back

SHOW TABLES;

Front

show tables in the database

Back

Database: RDBMS: Table: Record: Field: SQL Query: SQL Clause:

Front

Database: is an organized collection of data and contains multiple tables RDBMS: a Relational Database Management system is software that allows for the storage and retrieval of data organized in tables in databases Table: contains data stored in rows and columns Record: a row in a table Field: a column in a table SQL Query: is a type of SQL command used to retrieve data from existing data tables. A SQL query always starts with the SQL keyword SELECT. SQL Clause: a portion of a SQL query

Back

String Manipulation: Wildcard Comparisons SELECT country LIKE 'U%' FROM movies; SELECT country LIKE 'U_A' FROM movies;

Front

The LIKE operator in combination with wildcards _ and % are used for pattern matching. The percentage sign (%) is a wildcard used to define any number (zero or more) of missing characters both before and after a pattern. The underscore symbol (_) is a wildcard used to substitute for a single character or space.

Back

CURRENT_DATE() CURRENT_TIME() DATE()

Front

Date

Back