SQL 5
SQL 5
• UNION ALL
• INTERSECT ALL
• EXCEPT ALL
Set Operations
A A
5 6
4 5
NULL NULL
1 2
Dealing with NULL values in various contexts
• Logical expressions
A B A AND B A OR B
T T T T
T F F T
F T F T
F F F F
T UK UK T
F UK F UK
UK UK UK UK
Dealing with NULL values in various contexts
• SELECT A FROM R WHERE B = NULL;
A B
a 1
b 2
• SELECT A FROM R WHERE B IS NULL;
c NULL
d NULL
•
BETWEEN
• It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.
• WHERE Column_name BETWEEN Val_1 AND Val_2;
• It is a comparison operator on numeric domain.
❖ Retrieve all the employees whore salary is between 30,000 and 50,000
➢ SELECT * FROM Emp WHERE salary BETWEEN 30000 AND 50000;
❖ Insert records into Sample table from Emp table whose salary is between
20000 and 30000 given that both tables have same structure.
➢ INSERT INTO SSAMPLE(SELECT * FROM Emp
WHERE salary BETWEEN 20000 AND 30000);
❖ Retrieve all the employees whore salary is not between 30,000 and 50,000
➢ SELECT * FROM Emp WHERE salary NOT BETWEEN 30000 AND 50000;
BETWEEN
• It is also a comparison operator on text and dates