Save
Databases Final
SELECT WHERE
Save
Share
Learn
Content
Leaderboard
Learn
Created by
tiana okane
Visit profile
Cards (36)
SQL
Structure Query Language - an international standard language to create, read, update, delete data from a database and its
entities
View source
Many data-driven applications/websites use SQL to retrieve, format,
report
, insert,
delete
and to modify data for users
View source
SQL
is designed to be
human-readable
View source
SQL
commands
SELECT
name FROM Customer WHERE customerNo = 12345;
UPDATE
Student SET Status = "Confused" WHERE studentNo = 789123;
INSERT
INTO Pet(name, type) VALUES("Fido","Doggo");
DELETE
FROM Minions WHERE Death = 1;
View source
3
Main Parts of SQL
Data Manipulation Language
(
DML
)
Data Definition Language
(
DDL
)
Data Control Language
(
DCL
)
View source
Data Manipulation Language
(DML)
Commands that maintain and query a database, to maintain data (Create,
Read
, Update,
Delete
) and data query (through the use of SELECT statements to read information)
View source
Data
Definition Language (DDL)
Schema creation and modification, used to define and manage database
structures
(CREATE TABLE, ADD INDEX, etc.)
View source
Data
Control Language (
DCL
)
For creating user accounts, managing
permissions
,
security
, etc.
View source
Data
Query and Manipulation
Data Query
(Fetching data sets depending on certain criteria, using SELECT statements)
Data Manipulation
(Insert, Update, Delete)
View source
SELECT
The most common SQL statement, reads information from the database that
matches
the specified criteria
View source
SELECT * FROM...
retrieves
an
entire table
, with * meaning 'everything'
View source
SELECT
column(s) FROM table(s) [ WHERE query ] is the general syntax for
SELECT
statements
View source
SELECT NAME FROM
Pet
;
retrieves
a single column of records
View source
SELECT
PetID, NAME FROM Pet; retrieves multiple
columns
of records
View source
WHERE clause
Used to create conditions for the
output
data to
match
View source
SELECT
* FROM Pet WHERE TYPE =
'Dog'
;
Retrieves all
columns
, but only for records where the Type is
'Dog'
View source
SELECT * FROM Pet WHERE AGE = 3;
Retrieves all
columns
, but only for records where the Age is
3
View source
The WHERE clause is not only used in SELECT statements, but also in
UPDATE
,
DELETE
, etc.
View source
The
WHERE clause can be combined with AND and
OR
relational operators
View source
AND
Represents an
intersection
(A Ç B) of the data sets
View source
OR
Represents the
union
(A È B) of the
data
sets
View source
WHERE
is not exclusive to
SELECT
View source
The
WHERE clause is not only used in
SELECT
statements
View source
It is also used in
UPDATE
,
DELETE
, etc.
View source
Learn
to query – using
online tool
on MySQL
View source
make
sure this part shows 'mySQL' and not 'SQL'
View source
Relational Operators in the WHERE clause
The WHERE clause can be combined with
AND
and
OR
relational operators
AND, OR are used to display
records
in the entity table if all the conditions are
TRUE
View source
AND
Represent an
intersection
(A Ç B) of the data sets
View source
OR
To represent the union (A È B) of the
data
sets
View source
SELECT
* FROM Pet WHERE (Type = 'Turtle') OR (Type = 'Owl')
Retrieve all relevant records, where Type = 'Turtle', 'Owl' or both (
UNION
condition) is met
View source
SELECT
NAME FROM Pet WHERE (TYPE = 'Dog') AND (Age > 5)
Retrieve all Names, where
Type
= 'Dog' and
Age
>5 (INTERSECTION condition) is met
View source
SQL
keywords and Statements are
NOT
case sensitive
View source
Text
Fields vs. Numeric Fields: SQL requires
single
quotes '…' around text values, numeric fields should not be enclosed in quotes
View source
Semicolon
(
;
) after SQL statements is optional for a single SQL statement, must use ; with multiple SQL statements
View source
SELECT
* FROM Pet WHERE TYPE =
'DDog'
View source
SELECT
* FROM Pet WHERE TTYPE =
'Dog'
View source