Database Management System
Database Management System
DataMore
2-27
DBMS (MSBTE-Sem. 3-Comp)
2.16.1 Arithmetic Operators
Syntax y where value
Consider two operands
x
and ofx is 10 while y
is 5.
name) from name;
table
SELECT distinct( column Operators Deseriptions Examples
It adds the operands X+y=l5
Example + (Add)
-
(Subtract) It subtracts right hand operand x-y=s
emp;
select distinct(job) from from left hand operand
Salesman
2.16.2 Comparison Operators
y
Consider two operands x and y where value of x is 10 while is 5
Operators- Arithmetic
Syllabus Topic : SQL
escriptions Examples
Operators, Comparison Operators, Logical Operators
Operators Check whether both the X=y is not true
operands have same values, if
SQL Operators yes condition becomes true.
2.16
Check whether left operand is X>yis true
a.2.16.1 Explain SQL Operators. greater than right, if yes
(Hefer sections 2.16 to 2.16.5) (4 Marks) condition becomes true
< Check whether left operand is X<y is not true
An operator is a character or reserved word used in SQL less than right, if yes condition
statements to perform different operations like arithmetic or becomes true
comparison. Check whether left operand is X>=y is true
greater than or equal to the right
Operators are used to specify conditions in an SQL statement operand or not, if yes condition
and also used to integrate multiple conditions in SOL
become true
Check whether left operand is not
statement. is X<=y
less than or equal to the
right true
SQL Operators operand or not, if yes condition
become true
Check whether both the
1. Arithmetíc operators x !=y is true
operands have same
not, if not values or
2. Comparison operators condition become
true. wh
3. Logical operators Check whether Ou
operands have same both the XOy is true
not, if not values or
4. Bit wise operators condition become
true.
5. Cornpound operators A Check whether
not greater left operand not
operators than the value is x>=y is
Fig. 2.16.1: SQL right operand of true
Check whether Sele
not less left operand
than the right is
value operand |
xk=y is true whe
Ddel
DBMS (MSBTE-Sem. 3-Comp)
2-28 Rolational Data Modol
Table
5. Consider following
e
7844 TURNER SALESMAN 7698 09/08/1981 1500 30
e G =Equal to
Output
PGreater Than
where
sal>3000;
Output
Output
Output
EMPNOENAME JOB
MGRIREDATE| SAL,COMMDEVINO
7654 MARTIN SALESMAN
(D2B/19%1 1230 1400
7844 TURNER SALESMAN
(KIR/198I 150
7876 ADAMS CURK 778% 01/12/1983 I100
7900 JAMES CLERK
798 12/03W1981 950
7934 MILLER CLERK 7782 0123/1982 1300
oNot Equal To
2850 30
7698 BLAKE MANAGER 7839 0S/01/1981
2450 10
7782 CLARK MANAGER 7839 06/09/1981
04/02/1981 2975 20
7566 JONES MANAGER 7839
Combination of operators
can be used with AND operator
3. Intersect
2.16.4 Bitwise Operators
4. Minus
Operator Description
Fig. 2.17.1 : Set operators Select
& Bitwise AND
Consider following two tables Emp and Dept Union
Bitwise OR
Bitwise excusive OR Table 2.17.1: Emp Select
intersect
20
30 Select column name from table2
40
G'Example
2.17.2 Union AI
Select
l
emp
GDeptNo from
The Union All operator returns all rows selected by either
Intersect
query including duplicates.
selectDeptno from dept
G Syntax
Output
Select column name from table 1
10
Union all?
20
10 minus
30 G Example
30
Output
40 40
Relational
Data Moce
-lDBMS
2-33
DBMS (MSBTE-Sem. 3-Comp)
Between r Examp
Operators-
: Range Searching Query
Syllabus Topic
- Between select * fro
Range Searching Operators (MSBTE -W-13
2.18 where
enan
W-13,2 Marks
"BETWEEN (Refer section
2.18) Output
Explain range searching operator,
.2.18.1 keyword is used in this
predicate.
range of values. The AND
to specify certain
Between predicate is used
Syntax
expression AND end expression
test expression [NOTI BETWEEN begin
G Exar
F Example Fue
Output Output
HIREDATE SAL COMM DEPTNO
EMPNO ENAME JOBMGR
7499 ALLEN SALESMAN 7698 02/20/1981 1600 300
Output select
950 30
7900 JAMES CLERK 7698 12/03/1981
Query
%N;
where ename like
Output
HIREDATE SAL |COMM DEPTNO
JOB MGR
EMPNOENAME
7698 1600 300 30
SALESMAN 02/20/1981
7499 ALLEN
Query
select * fromemp
Output
Warks
G Query
egul select
from emp
aractes
Theus
Where ename like '%A%;
Belational Data
2-35
M
(MSBTE-Sem. 3-Comp)
COMM DEPTNO
Output IREDATE SAL
MGR
EMPNO ENAME JOB
2850 30
05/01/1981
MANAGER 7839
7698 BLAKE 10
06/09/198
1
2450
MANAGER 7839
CLARK
7782 300 30
02/20/198 1 1600
SALESMAN 7698
7499 ALLEN
1250 500 30
SALESMAN 7698 02/22/198 1
: a. 2
(iii) Select fist_name "Employee Name" fromemployee; (ii) Select count * from Book_master order by author;
óv) Select Itrim(first_name) from employee; (iii) Select count * from Book _master where price between 200
(i) Select * from employee where join_date > '01-Apr.- 1997; (ii) Select * from emp where job in ("Manager' or “Analyst');
(iv) Select count(*) from employee where deptno = 10; (iii) Update emp set loc = 'Pune' where deptno = 40 and
loc = Chandrapur
Q.219.7 Consider the structure for book table as
Book master (book id, book _name, subcode, (iv) Select ename,salary from emp where salary > 50000 and
author,no_ of_copies, price). deptno in(10,30);