Week5 DBMS PDF
Week5 DBMS PDF
CSC 220
Outline
The WHERE clause can be combined with AND, OR, and NOT
operators.
The AND and OR operators are used to filter records based on more
than one condition
The AND operator displays a record if all the conditions separated by
AND are TRUE.
The OR operator displays a record if any of the conditions separated
by OR is TRUE.
The NOT operator displays a record if the condition(s) is NOT TRUE.
SQL AND,
AND Syntax
SQL OR,
OR Syntax
SQL NOT,
NOT Syntax
Demo Database
Scenario
Outline
Example
Write SQL statement that selects all fields from "Customers" where
country is NOT "Germany" and NOT "USA":.
Example
Outline
ORDER BY Syntax
Example
Write the SQL statement that selects all customers from the
"Customers" table, sorted by the "Country" column?
Example
Scenario
Write the SQL statement that selects all customers from the
"Customers" table, sorted DESCENDING by the "Country" column?
Write the SQL statement that selects all customers from the
"Customers" table, sorted by the "Country" and the
"CustomerName" column.
Write SQL statement that selects all customers from the "Customers"
table, sorted ascending by the "Country" and descending by the
"CustomerName" column?
Outline
Scenario-1
Problem: List all customers from Spain or France from the table given
below
Problem: List all customers that are not from the USA
Outline
Scenario-2
Problem: List all orders that not between $50 and $15000
Scenario-2 Soloution
Problem: List all orders that not between $50 and $15000
Outline
4 Scenarios
Scenario-1
Scenario-2
6 Takeaway!
Takeaway!
Strcuture definition
Syntax of SQL
DML Operations
How to read a statement for a possible query