Knowledge & Skill Forum
Introduction to SQL
Class 1 of SQL Training Program
1. Introduction to SQL
2. Basic Queries and Filtering
3. Aggregate Functions and Grouping
Training Plan 4. Joining Tables
5. Subqueries and Nested Queries
6. Data Modification and Advanced Topics
● What is SQL
● What is a Database
● Importance of SQL in Data
Agenda Management
● Basic SQL Syntax
● Command Type
What is SQL
SQL (Structured Query Language) is a standard language for accessing and
manipulating databases.
Purpose: Used to perform tasks such as querying, inserting, updating, and
deleting data in a database.
What is a Database
A database is an organized collection Example:
of structured information, or data,
typically stored electronically in a ● MySQL
computer system. ● Microsoft SQL Server
● PostgreSQL
Purpose: Databases make data ● Oracle Database
management easy and efficient,
allowing for data storage, retrieval,
and manipulation.
● Data Retrieval: Efficiently query
large datasets.
Importance of ● Data Manipulation: Insert, update,
and delete records.
SQL in Data ● Data Definition: Create and modify
database structures.
Management ● Data Control: Manage user access
and permissions.
Basic SQL Syntax
Query Structure:
Keywords:
SELECT column1, column2
SELECT, FROM, WHERE, FROM table_name
INSERT, UPDATE, DELETE, WHERE condition;
CREATE, ALTER, DROP
SELECT *|{[DISTINCT]
column|expression
[alias],...} FROM table;
Example:
SELECT *
FROM Students
WHERE age > 18;
SQL Statements
•SQL statements are not case sensitive.
•SQL statements can be entered on one or more lines.
•Keywords cannot be abbreviated or split across lines.
•Clauses are usually placed on separate lines.
•Indents are used to enhance readability.
•SQL statements can be optionally terminated by a semicolon (;). Semicolons
are required when you execute multiple SQL statements.
SQL Command Type
Thank You
● Execute queries against a database
● Retrieve data from a database
● Insert records in a database
● Update records in a database
● Delete records from a database
SQL Use case ● Create new databases
● Create new tables in a database
● Create stored procedures in a database
● Create views in a database
● Set permissions on tables, procedures, and
views
Knowledge & Skill Forum
Basic Queries and Filtering
Class 2 of SQL Training Program
● What is SQL Query
● Common Queries
Basic Query
Agenda ●
● Basic SQL Syntax
● Command Type
SQL Platform
What is SQL Query
SQL stands for Structured Query Language. It's a programming language
specifically designed for managing and manipulating data within relational
databases. Think of a database as a collection of organized information,
structured in tables with rows and columns.
An SQL query is essentially a question you ask the database. It's a command
you write using SQL syntax to retrieve, modify, or manage data.
Common SQL Query Types
SELECT: Used to retrieve data from a UPDATE: Used to modify existing
database. data in a database.
Example: SELECT * FROM customers; Example: UPDATE customers SET
(Retrieves all data from the email = '
[email protected]'
'customers' table) WHERE id = 1;
INSERT: Used to insert new data into DELETE: Used to remove data from a
a database. database.
Example: INSERT INTO customers Example: DELETE FROM orders
(name, email) VALUES ('John Doe', WHERE order_date < '2023-01-01';
'
[email protected]');
Basic SQL Query
SELECT: Used to retrieve Specify Column names to retrieve all
data from a database. records in the listed columns
Use ‘*’ For all Columns Example:
Example: SELECT * FROM customers; 1. SELECT Country FROM Customers;
(Retrieves all data from the
2. SELECT CustomerName, City,
'customers' table)
Country FROM Customers;
SELECT * FROM categories;
3. SELECT DISTINCT Country FROM
(Retrieves all data from the
Customers;
'categories' table)
Filtering In SQL Query
WHERE: Used to Filter data Example
1. Select all records where the CustomerID
from a database. has the value 3
2. Select all records where the City column
Operators has the value "Berlin"
3. Selects all fields from "Customers" where
= Equals BETWEEN country is "Germany" AND city is "Berlin"
4. Selects all fields from "Customers" where
> Greater than LIKE city is "Berlin" OR "Stuttgart"
5. Selects all fields from "Customers" where
< Less than IN
country is NOT "Germany"
<= Less than or Equal AND & OR
6. Selects all fields from "Customers" where
country is "Germany" AND city must be
<>/!= Not equal NOT "Berlin" OR "Stuttgart" (use parenthesis to
form complex expressions)
IS Null/Is Not Null 7. Select all records where the City column
has the value 'Berlin' and the PostalCode
column has the value 12209
Filtering In SQL Query
Operators Example
1. Customername that start with "a"
= Equals BETWEEN 2. Customername that end with "a"
3. Customername that have "or" in any
> Greater than LIKE
position
< Less than IN 4. Customername that have "r" in the second
position
<= Less than or Equal AND & OR 5. Customername start with "a" and are at
least 2 characters in length
<>/!= Not equal NOT 6. Customername start with "a" and are at
least 3 characters in length
Example 7. Contactname that start with "a" and ends
1. Select all records where the Address is with "o"
Null 8. selects all products with a price between
2. Select all records from the Customers 10 and 20
where the PostalCode column is empty 9. selects all products with a price between
3. Selects all customers that are located in 10 and 20. In addition; do not show
products with a CategoryID of 1,2, or 3
"Germany", "France" or "UK"
Thank You