lab 6
lab 6
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
select * from branch inner join staff on branch.branchno =
staff.branchno
Database Systems
✓ Where Clause
✓ Operators used in SQL
✓ Logical Operators
Where Clause
✓ Used to filter the records
✓ Used with select statement
✓ Used to update data of records
✓ Used to delete records
✓ Can also use to join more than one table
Use of IN Operator
✓ Select * from staff where position IN
('MANAGER','SUPERVISOR')
Staff
Agenda
✓ SQL Update
✓ SQL Delete
✓ SQL Select Top
✓ SQL ORDER BY
✓ SQL Aliases
✓ SQL MIN() and MAX() Functions
✓ SQL COUNT(), AVG() and SUM() Functions
The SQL UPDATE Statement
✓ UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
✓ Update staff
set salary = 20000
where staffno='SG14’
✓ Update staff
set salary = 20000
UPDATE Multiple Records
✓ Update staff
set position='Supervisor’
where position='Assistant’
✓ Update staff
set salary=17000
where position='Supervisor' AND salary < 17000
The SQL DELETE Statement
✓ DELETE FROM table_name WHERE condition;
✓ DELETE FROM Staff WHERE staffno = 'SA9’
✓ DELETE FROM Staff WHERE staffno = ‘SL21’ AND
BranchNo=‘B005’
✓ DELETE FROM Staff WHERE staffno = ‘SA9’
SQL Aliases
✓ SQL aliases are used to give a table, or a column in a table, a temporary name.
✓ Aliases are often used to make column names more readable.
✓ An alias only exists for the duration of the query.
Summary
✓ SQL Update
✓ SQL Delete
✓ SQL Select Top
✓ SQL ORDER BY
✓ SQL Aliases
✓ SQL MIN() and MAX() Functions
✓ SQL COUNT(), AVG() and SUM() Functions