SQL Basics
SQL Basics
SQL BASICS
Week 12: SQL Basics
DATABASE QUERIES
Week 12: SQL Basics
COMPOUND CONDITIONS
Compound Conditions use logical operators to filter or connect multiple criteria.
The WHERE clause can be combined with AND, OR, and NOT operators.
Week 12: SQL Basics
AND OPERATOR
AND operator displays a record if all the conditions separated by AND are TRUE.
AND Syntax
SELECT [ Column(s), or other expression]
FROM [Table(s)]
[WHERE condition 1 AND condition 2 AND condition 3 …:]
AND Examples
SELECT *
FROM Products
WHERE Price <= 20 AND Price >=10;
Week 12: SQL Basics
OR OPERATOR
OR operator displays a record if any of the conditions separated by OR is TRUE.
OR Syntax
ORDER BY KEYWORD
Used to sort the result. Sorts the records in ascending order by default.
To sort the records in descending order, use the DESC keyword.
ORDER BY Syntax
SELECT [ Column(s), or other expression]
FROM [Table(s)]
[ORDER BY column 1, column 2, … ASC/DESC;]
ORDER BY Examples
SELECT *
FROM Customers
ORDER BY Country;
Week 12: SQL Basics
TABLE JOIN
Table join use to retrieve data from multiple tables. The query result consists of columns from more
than one table.
To match rows from different table we will use two (2) Join.
Cross Join – NO need to match
Inner Join – Used the foreign key as the matching criteria
Week 12: SQL Basics
Week 12: SQL Basics