SlideShare a Scribd company logo
1 of 14
Download to read offline
Practical No: 3
Problem Statement: Design at least 10 SQL queries for suitable database
application using SQL DML statements:
Insert, Select, Update, Delete with operators, functions, and set operator.
mysql> use prac3;
Database changed
mysql> DROP TABLE IF EXISTS emp;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
mysql> CREATE TABLE emp (
-> empno decimal(4,0) NOT NULL,
-> ename varchar(10) default NULL,
-> job varchar(9) default NULL,
-> mgr decimal(4,0) default NULL,
-> hiredate date default NULL,
-> sal decimal(7,2) default NULL,
-> comm decimal(7,2) default NULL,
-> deptno decimal(2,0) default NULL
-> );
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql> DROP TABLE IF EXISTS dept;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
mysql> CREATE TABLE dept (
-> deptno decimal(2,0) default NULL,
-> dname varchar(14) default NULL,
-> loc varchar(13) default NULL
-> );
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> INSERT INTO emp VALUES ('7369','SMITH','CLERK','7902','1980-12-
17','800.00',NULL,'20');
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO emp VALUES ('7499','ALLEN','SALESMAN','7698','1981-02-
20','1600.00','300.00','30');
Query OK, 1 row affected (0.04 sec)
mysql> INSERT INTO emp VALUES ('7521','WARD','SALESMAN','7698','1981-02-
22','1250.00','500.00','30');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7566','JONES','MANAGER','7839','1981-04-
02','2975.00',NULL,'20');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7654','MARTIN','SALESMAN','7698','1981-09-
28','1250.00','1400.00','30');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7698','BLAKE','MANAGER','7839','1981-05-
01','2850.00',NULL,'30');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7782','CLARK','MANAGER','7839','1981-06-
09','2450.00',NULL,'10');
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO emp VALUES ('7788','SCOTT','ANALYST','7566','1982-12-
09','3000.00',NULL,'20');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7839','KING','PRESIDENT',NULL,'1981-11-
17','5000.00',NULL,'10');
Query OK, 1 row affected (0.00 sec)
mysql> select ename, sal frommysql> select ename, sal from emp where sal between
1000 and 5000;
+--------+---------+
| ename | sal |
+--------+---------+
| ALLEN | 1600.00 |
| WARD | 1250.00 |
| JONES | 2975.00 |
| MARTIN | 1250.00 |
| BLAKE | 2850.00 |
| CLARK | 2450.00 |
| SCOTT | 3000.00 |
| KING | 5000.00 |
| TURNER | 1500.00 |
| ADAMS | 1100.00 |
| FORD | 3000.00 |
| MILLER | 1300.00 |
+--------+---------+
12 rows in set (0.00 sec)
emp where sal between 1000 and 5000;
+--------+---------+
| ename | sal |
+--------+---------+
| ALLEN | 1600.00 |
| WARD | 1250.00 |
| JONES | 2975.00 |
| MARTIN | 1250.00 |
| BLAKE | 2850.00 |
| CLARK | 2450.00 |
| SCOTT | 3000.00 |
| KING | 5000.00 |
| TURNER | 1500.00 |
| ADAMS | 1100.00 |
| FORD | 3000.00 |
| MILLER | 1300.00 |
+--------+---------+
12 rows in set (0.00 sec)
mysql> INSERT INTO emp VALUES ('7844','TURNER','SALESMAN','7698','1981-09-
08','1500.00','0.00','30');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7876','ADAMS','CLERK','7788','1983-01-
12','1100.00',NULL,'20');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7900','JAMES','CLERK','7698','1981-12-
03','950.00',NULL,'30');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7902','FORD','ANALYST','7566','1981-12-
03','3000.00',NULL,'20');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES ('7934','MILLER','CLERK','7782','1982-01-
23','1300.00',NULL,'10');
Query OK, 1 row affected (0.01 sec)
mysql>
mysql> INSERT INTO dept VALUES ('10','ACCOUNTING','NEW YORK');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO dept VALUES ('20','RESEARCH','DALLAS');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO dept VALUES ('30','SALES','CHICAGO');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO dept VALUES ('40','OPERATIONS','BOSTON');
Query OK, 1 row affected (0.00 sec)
mysql> desc emp;
+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| empno | decimal(4,0) | NO | | NULL | |
| ename | varchar(10) | YES | | NULL | |
| job | varchar(9) | YES | | NULL | |
| mgr | decimal(4,0) | YES | | NULL | |
| hiredate | date | YES | | NULL | |
| sal | decimal(7,2) | YES | | NULL | |
| comm | decimal(7,2) | YES | | NULL | |
| deptno | decimal(2,0) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
8 rows in set (0.00 sec)
mysql> select * from emp;
+-------+--------+-----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+-----------+------+------------+---------+---------+--------+
| 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 |
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 |
| 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 |
| 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 |
+-------+--------+-----------+------+------------+---------+---------+--------+
14 rows in set (0.00 sec)
mysql> select distinct(job) from emp;
+-----------+
| job |
+-----------+mysql> select ename, sal from emp where sal between 1000 and 5000;
+--------+---------+
| ename | sal |
+--------+---------+
| ALLEN | 1600.00 |
| WARD | 1250.00 |
| JONES | 2975.00 |
| MARTIN | 1250.00 |
| BLAKE | 2850.00 |
| CLARK | 2450.00 |
| SCOTT | 3000.00 |
| KING | 5000.00 |
| TURNER | 1500.00 |
| ADAMS | 1100.00 |
| FORD | 3000.00 |
| MILLER | 1300.00 |
+--------+---------+
12 rows in set (0.00 sec)
| CLERK |
| SALESMAN |
| MANAGER |
| ANALYST |
| PRESIDENT |
+-----------+
5 rows in set (0.00 sec)
mysql> select empno,ename,sal from emp where deptno=20 ;
+-------+-------+---------+
| empno | ename | sal |
+-------+-------+---------+
| 7369 | SMITH | 800.00 |
| 7566 | JONES | 2975.00 |
| 7788 | SCOTT | 3000.00 |
| 7876 | ADAMS | 1100.00 |
| 7902 | FORD | 3000.00 |
+-------+-------+---------+
5 rows in set (0.00 sec)
mysql> select empno,ename,sal from emp where deptno like 20 ;
+-------+-------+---------+
| empno | ename | sal |
+-------+-------+---------+
| 7369 | SMITH | 800.00 |
| 7566 | JONES | 2975.00 |
| 7788 | SCOTT | 3000.00 |
| 7876 | ADAMS | 1100.00 |
| 7902 | FORD | 3000.00 |
+-------+-------+---------+
5 rows in set (0.00 sec)
mysql> select empno,ename,sal from emp where ename like 'a%' ;
+-------+-------+---------+
| empno | ename | sal |
+-------+-------+---------+
| 7499 | ALLEN | 1600.00 |
| 7876 | ADAMS | 1100.00 |
+-------+-------+---------+
2 rows in set (0.00 sec)
mysql> select * from emp where ename like '__N%';
+-------+-------+-----------+------+------------+---------+------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+-------+-----------+------+------------+---------+------+--------+
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
+-------+-------+-----------+------+------------+---------+------+--------+
2 rows in set (0.00 sec)
mysql> select deptno as DEPTNO, MAX(sal) as "MAXIMUM SALARY" from emp group by
(deptno);
+--------+----------------+
| DEPTNO | MAXIMUM SALARY |
+--------+----------------+
| 10 | 5000.00 |
| 20 | 3000.00 |
| 30 | 2850.00 |
+--------+----------------+
3 rows in set (0.00 sec)
mysql> select count(sal) from emp where sal=3000;
+------------+
| count(sal) |
+------------+
| 2 |
+------------+
1 row in set (0.00 sec)
mysql> select MAX(sal) from emp;
+----------+
| MAX(sal) |
+----------+
| 5000.00 |
+----------+
1 row in set (0.00 sec)
mysql> select MIN(sal) from emp;
+----------+
| MIN(sal) |
+----------+
| 800.00 |
+----------+
1 row in set (0.00 sec)
mysql> select MIN(sal) least, MAX(sal) max from emp;
+--------+---------+
| least | max |
+--------+---------+
| 800.00 | 5000.00 |
+--------+---------+
1 row in set (0.00 sec)
mysql> select deptno , MIN(sal) "MINIMUM SALARY" from emp group by (deptno);
+--------+----------------+
| deptno | MINIMUM SALARY |
+--------+----------------+
| 10 | 1300.00 |
| 20 | 800.00 |
| 30 | 950.00 |
+--------+----------------+
3 rows in set (0.00 sec)
mysql> select SUM(sal) totalsal from emp;
+----------+
| totalsal |
+----------+
| 29025.00 |
+----------+
1 row in set (0.00 sec)
mysql> select deptno , SUM(sal) "sal sum" from emp group by (deptno);
+--------+----------+
| deptno | sal sum |
+--------+----------+
| 10 | 8750.00mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
|
| 20 | 10875.00 |
| 30 | 9400.00 |
+--------+----------+
3 rows in set (0.00 sec)
mysql> select deptno , avg(sal) "sal avg" from emp group by (deptno);
+--------+-------------+
| deptno | sal avg |
+--------+-------------+
| 10 | 2916.666667 |
| 20 | 2175.000000 |
| 30 | 1566.666667 |
+--------+-------------+
3 rows in set (0.00 sec)
mysql> select * from emp where job in('CLERK','PRESIDENT');
+-------+--------+-----------+------+------------+---------+------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+-----------+------+------------+---------+------+--------+
| 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
| 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 |
+-------+--------+-----------+------+------------+---------+------+--------+
5 rows in set (0.00 sec)
mysql> select * from emp where job not in('CLERK','PRESIDENT');
+-------+--------+----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+----------+------+------------+---------+---------+--------+
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 |
| 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 |
+-------+--------+----------+------+------------+---------+---------+--------+
9 rows in set (0.00 sec)
mysql> select * fromysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
m emp order by comm;
+-------+--------+-----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+-----------+------+------------+---------+---------+--------+
| 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 |
| 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 |
| 7782 | CLARK |
mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 |
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
+-------+--------+-
mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
----------+------+------------+---------+---------+--------+
14 rows in set (0.00 sec)
mysql> select * from emp where comm <> 'NULL';
+-------+--------+----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+----------+------+------------+---------+---------+--------+
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
+-------+--------+----------+------+------------+---------+---------+--------+
3 rows in set, 1 warning (0.00 sec)
mysql> select * from emp where comm <> 'NULL' order by comm desc;
+-------+--------+----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+----------+------+------------+---------+---------+--------+
| 7654 | MARTIN | mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
sec)
SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
+-------+--------+----------+------+------------+---------+---------+--------+
3 rows in set, 1 warning (0.00 sec)
mysql> select ename, sal from emp where sal between 1000 and 5000;
+--------+---------+mysql> select ename, sal from emp where sal between 1000 and
5000;
+--------+---------+
| ename | sal |
+--------+---------+
| ALLEN | 1600.00 |
| WARD | 1250.00
mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
|
| JONES | 2975.00 |
| MARTIN | 1250.00 mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
|
| BLAKE | 2850.00 |
| CLARK | 2450.00 |
| SCOTT | 3000.00 |
| KING | 5000.00 |
| TURNER | 1500.00 |
| ADAMS | 1100.00 |
| FORD | 3000.00 |
| MILLER | 1300.00 |
+--------+---------+
12 rows in set (0.00 sec)
| ename | sal |
+--------+---------+
| ALLEN | 1600.00 |
| WARD | 1250.00 |
| JONES | 2975.00 |
| MARTIN | 1250.00 |
| BLAKE | 2850.00 |
| CLARK | 2450.00 |
| SCOTT | 3000.00 |
| KING | 5000.00 |
| TURNER | 1500.00 |
| ADAMS | 1100.00 |
| FORD | 3000.00 |
| MILLER | 1300.00 |
+--------+---------+
12 rows in set (0.00 sec)
mysql> select empno,ename,job,comm,sal from emp where sal>=1000 and sal<=3000;
+-------+--------+----------+---------+---------+
| empno | ename | job | comm | sal |
+-------+--------+----------+---------+---------+
| 7499 | ALLEN | SALESMAN | 300.00 | 1600.00 |
| 7521 | WARD | SALESMAN | 500.00 | 1250.00 |
| 7566 | JONES | MANAGER | NULL | 2975.00 |
| 7654 | MARTIN | SALESMAN | 1400.00 | 1250.00 |
| 7698 | BLAKE | MANAGER | NULL | 2850.00 |
| 7782 | CLARK | MANAGER | NULL | 2450.00 |
| 7788 | SCOTT | ANALYST | NULL | 3000.00 |
| 7844 | TURNER | SALESMAN | 0.00 | 1500.00 |
| 7876 | ADAMS | CLERK | NULL | 1100.00 |
| 7902 | FORD | ANALYST | NULL | 3000.00 |
| 7934 | MILLER | CLERK | NULL | 1300.00 |
+-------+--------+----------+---------+---------+
11 rows in set (0.00 sec)
mysql> select empno,ename,job,comm,sal from emp where sal>=1000 or sal<=3000;
+-------+--------+-----------+---------+---------+
| empno | ename | job | comm | sal |
+-------+--------+-----------+---------+---------+
| 7369 | SMITH | CLERK | NULL | 800.00 |
| 7499 | ALLEN | SALESMAN | 300.00 | 1600.00 |
| 7521 | WARD | SALESMAN | 500.00 | 1250.00 |
| 7566 | JONES | MANAGER | NULL | 2975.00 |
| 7654 | MARTIN | SALESMAN | 1400.00 | 1250.00 |
| 7698 | BLAKE | MANAGER | NULL | 2850.00 |
| 7782 | CLARK | MANAGER | NULL | 2450.00 |
| 7788 | SCOTT | ANALYST | NULL | 3000.00 |
| 7839 | KING | PRESIDENT | NULL | 5000.00 |
| 7844 | TURNER | SALESMAN | 0.00 | 1500.00 |
| 7876 | ADAMS | CLERK | NULL | 1100.00 |
| 7900 | JAMES | CLERK | NULL | 950.00 |
| 7902 | FORD | ANALYST | NULL | 3000.00 |
| 7934 | MILLER | CLERK | NULL | 1300.00 |
+-------+--------+-----------+---------+---------+
14 rows in set (0.00 sec)
mysql> select empno,ename,job,comm,sal from emp where not sal=3000;
+-------+--------+-----------+---------+---------+
| empno | ename | job | comm | sal |
+-------+--------+-----------+---------+---------+
| 7369 | SMITH | CLERK | NULL | 800.00 |
| 7499 | ALLEN | SALESMAN | 300.00 | 1600.00 |
| 7521 | WARD | SALESMAN | 500.00 | 1250.00 |
| 7566 | JONES | MANAGER | NULL | 2975.00 |
| 7654 | MARTIN | SALESMAN | 1400.00 | 1250.00 |
| 7698 | BLAKE | MANAGER | NULL | 2850.00 |
| 7782 | CLARK | MANAGER | NULL | 2450.00 |
| 7839 | KING | PRESIDENT | NULL | 5000.00 |
| 7844 | TURNER | SALESMAN | 0.00 | 1500.00 |
| 7876 | ADAMS | CLERK | NULL | 1100.00 |
| 7900 | JAMES | CLERK | NULL | 950.00 |
| 7934 | MILLER | CLERK | NULL | 1300.00 |
+-------+--------+-----------+---------+---------+
12 rows in set (0.00 sec)
mysql> update emp set comm=520 where empno=7369;
Query OK, 1 row affected (0.37 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from emp;
+-------+--------+-----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+-----------+------+------------+---------+---------+--------+
| 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | 520.00 | 20 |
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 |
| 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 |
| 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 |
+-------+--------+-----------+------+------------+---------+---------+--------+
14 rows in set (0.00 sec)
mysql> delete from emp where empno=7369;
Query OK, 1 row affected (0.01 sec)
mysql> select * from emp;
+-------+--------+-----------+------+------------+---------+---------+--------+
| empno | ename | job | mgr | hiredate | sal | comm | deptno |
+-------+--------+-----------+------+------------+---------+---------+--------+
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 |
| 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 |
| 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 |
+-------+--------+-----------+------+------------+---------+---------+--------+
13 rows in set (0.00 sec)
________________________________________________________________________________
_______
mysql> select * from t1;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
5 rows in set (0.00 sec)
mysql> select * from t1 union select * from t2;
+-----+-------+
| Rno | Name |
+-----+-------+
| 1 | amit |
| 2 | rohan |
| 3 | rahul |
| 4 | Nayan |
| 5 | pati |
| 6 | xyz |
| 7 | pqr |
+-----+-------+
7 rows in set (0.00 sec)
mysql> select distinct(Rno) as "Common RollNo" from t1 inner join t2
using(Rno);
+---------------+
| Common RollNo |
+---------------+
| 3 |
| 4 |
| 5 |
+---------------+
3 rows in set (0.00 sec)

More Related Content

What's hot

aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.bhavesh lande
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3Mohd Tousif
 
Criminal Record Management System in the Perspective of Somalia
Criminal Record Management System in the Perspective of Somalia  Criminal Record Management System in the Perspective of Somalia
Criminal Record Management System in the Perspective of Somalia fowzi mohamed
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary searchNisha Soms
 
String function in my sql
String function in my sqlString function in my sql
String function in my sqlknowledgemart
 
A mini project on designing a DATABASE for Library management system using mySQL
A mini project on designing a DATABASE for Library management system using mySQLA mini project on designing a DATABASE for Library management system using mySQL
A mini project on designing a DATABASE for Library management system using mySQLsvrohith 9
 
SQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question BankSQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question BankMd Mudassir
 
Top 40 sql queries for testers
Top 40 sql queries for testersTop 40 sql queries for testers
Top 40 sql queries for testerstlvd
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answersvijaybusu
 
Car Rental Agency - Database - MySQL
Car Rental Agency - Database - MySQLCar Rental Agency - Database - MySQL
Car Rental Agency - Database - MySQLSotiris Baratsas
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithmtaimurkhan803
 
Prims & kruskal algorithms
Prims & kruskal algorithmsPrims & kruskal algorithms
Prims & kruskal algorithmsAyesha Tahir
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Treezhaokatherine
 

What's hot (20)

aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
 
Sql queires
Sql queiresSql queires
Sql queires
 
Criminal Record Management System in the Perspective of Somalia
Criminal Record Management System in the Perspective of Somalia  Criminal Record Management System in the Perspective of Somalia
Criminal Record Management System in the Perspective of Somalia
 
How to Use JSON in MySQL Wrong
How to Use JSON in MySQL WrongHow to Use JSON in MySQL Wrong
How to Use JSON in MySQL Wrong
 
MYSQL
MYSQLMYSQL
MYSQL
 
List in Python
List in PythonList in Python
List in Python
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
String function in my sql
String function in my sqlString function in my sql
String function in my sql
 
Heaptree
HeaptreeHeaptree
Heaptree
 
A mini project on designing a DATABASE for Library management system using mySQL
A mini project on designing a DATABASE for Library management system using mySQLA mini project on designing a DATABASE for Library management system using mySQL
A mini project on designing a DATABASE for Library management system using mySQL
 
SQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question BankSQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question Bank
 
Top 40 sql queries for testers
Top 40 sql queries for testersTop 40 sql queries for testers
Top 40 sql queries for testers
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 
Car Rental Agency - Database - MySQL
Car Rental Agency - Database - MySQLCar Rental Agency - Database - MySQL
Car Rental Agency - Database - MySQL
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Prims & kruskal algorithms
Prims & kruskal algorithmsPrims & kruskal algorithms
Prims & kruskal algorithms
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 

Similar to database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator.

database application using SQL DML statements: all types of Join, Sub-Query ...
 database application using SQL DML statements: all types of Join, Sub-Query ... database application using SQL DML statements: all types of Join, Sub-Query ...
database application using SQL DML statements: all types of Join, Sub-Query ...bhavesh lande
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
Statements project 2
Statements project 2Statements project 2
Statements project 2AlexisHarvey8
 
Perth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL TechniquesPerth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL TechniquesConnor McDonald
 
Mysqlfunctions
MysqlfunctionsMysqlfunctions
MysqlfunctionsN13M
 
Sangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQLSangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQLConnor McDonald
 
Analytics functions in mysql, oracle and hive
Analytics functions in mysql, oracle and hiveAnalytics functions in mysql, oracle and hive
Analytics functions in mysql, oracle and hiveAnkit Beohar
 
MySQL5.7で遊んでみよう
MySQL5.7で遊んでみようMySQL5.7で遊んでみよう
MySQL5.7で遊んでみようyoku0825
 
80 different SQL Queries with output
80 different SQL Queries with output80 different SQL Queries with output
80 different SQL Queries with outputNexus
 
SQL techniques for faster applications
SQL techniques for faster applicationsSQL techniques for faster applications
SQL techniques for faster applicationsConnor McDonald
 
Optimizing Queries Using Window Functions
Optimizing Queries Using Window FunctionsOptimizing Queries Using Window Functions
Optimizing Queries Using Window FunctionsI Goo Lee
 
ILOUG 2019 - SQL features for Developers
ILOUG 2019 - SQL features for DevelopersILOUG 2019 - SQL features for Developers
ILOUG 2019 - SQL features for DevelopersConnor McDonald
 

Similar to database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator. (20)

database application using SQL DML statements: all types of Join, Sub-Query ...
 database application using SQL DML statements: all types of Join, Sub-Query ... database application using SQL DML statements: all types of Join, Sub-Query ...
database application using SQL DML statements: all types of Join, Sub-Query ...
 
Mysql and html
Mysql and html Mysql and html
Mysql and html
 
Empresa completo
Empresa completoEmpresa completo
Empresa completo
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
Analytic SQL Sep 2013
Analytic SQL Sep 2013Analytic SQL Sep 2013
Analytic SQL Sep 2013
 
Statements project 2
Statements project 2Statements project 2
Statements project 2
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
Perth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL TechniquesPerth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL Techniques
 
Mysqlfunctions
MysqlfunctionsMysqlfunctions
Mysqlfunctions
 
Sangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQLSangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQL
 
Cube rollup slides
Cube rollup slidesCube rollup slides
Cube rollup slides
 
Analytics functions in mysql, oracle and hive
Analytics functions in mysql, oracle and hiveAnalytics functions in mysql, oracle and hive
Analytics functions in mysql, oracle and hive
 
MySQL5.7で遊んでみよう
MySQL5.7で遊んでみようMySQL5.7で遊んでみよう
MySQL5.7で遊んでみよう
 
80 different SQL Queries with output
80 different SQL Queries with output80 different SQL Queries with output
80 different SQL Queries with output
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
 
SQL techniques for faster applications
SQL techniques for faster applicationsSQL techniques for faster applications
SQL techniques for faster applications
 
Optimizing Queries Using Window Functions
Optimizing Queries Using Window FunctionsOptimizing Queries Using Window Functions
Optimizing Queries Using Window Functions
 
Cassandra & Maria DB
Cassandra & Maria DBCassandra & Maria DB
Cassandra & Maria DB
 
Tugas praktikum smbd
Tugas praktikum smbdTugas praktikum smbd
Tugas praktikum smbd
 
ILOUG 2019 - SQL features for Developers
ILOUG 2019 - SQL features for DevelopersILOUG 2019 - SQL features for Developers
ILOUG 2019 - SQL features for Developers
 

More from bhavesh lande

The Annual G20 Scorecard – Research Performance 2019
The Annual G20 Scorecard – Research Performance 2019 The Annual G20 Scorecard – Research Performance 2019
The Annual G20 Scorecard – Research Performance 2019 bhavesh lande
 
information control and Security system
information control and Security systeminformation control and Security system
information control and Security systembhavesh lande
 
information technology and infrastructures choices
information technology and  infrastructures choicesinformation technology and  infrastructures choices
information technology and infrastructures choicesbhavesh lande
 
ethical issues,social issues
 ethical issues,social issues ethical issues,social issues
ethical issues,social issuesbhavesh lande
 
managing inforamation system
managing inforamation systemmanaging inforamation system
managing inforamation systembhavesh lande
 
• E-commerce, e-business ,e-governance
• E-commerce, e-business ,e-governance• E-commerce, e-business ,e-governance
• E-commerce, e-business ,e-governancebhavesh lande
 
organisations and information systems
organisations and  information systemsorganisations and  information systems
organisations and information systemsbhavesh lande
 
IT stratergy and digital goods
IT stratergy and digital goodsIT stratergy and digital goods
IT stratergy and digital goodsbhavesh lande
 
Implement Mapreduce with suitable example using MongoDB.
 Implement Mapreduce with suitable example using MongoDB. Implement Mapreduce with suitable example using MongoDB.
Implement Mapreduce with suitable example using MongoDB.bhavesh lande
 
Unnamed PL/SQL code block: Use of Control structure and Exception handling i...
 Unnamed PL/SQL code block: Use of Control structure and Exception handling i... Unnamed PL/SQL code block: Use of Control structure and Exception handling i...
Unnamed PL/SQL code block: Use of Control structure and Exception handling i...bhavesh lande
 
applications and advantages of python
applications and advantages of pythonapplications and advantages of python
applications and advantages of pythonbhavesh lande
 
introduction of python in data science
introduction of python in data scienceintroduction of python in data science
introduction of python in data sciencebhavesh lande
 
data scientists and their role
data scientists and their roledata scientists and their role
data scientists and their rolebhavesh lande
 
statistics techniques to deal with data
statistics techniques to deal with datastatistics techniques to deal with data
statistics techniques to deal with databhavesh lande
 
introduction to data science
introduction to data scienceintroduction to data science
introduction to data sciencebhavesh lande
 

More from bhavesh lande (19)

The Annual G20 Scorecard – Research Performance 2019
The Annual G20 Scorecard – Research Performance 2019 The Annual G20 Scorecard – Research Performance 2019
The Annual G20 Scorecard – Research Performance 2019
 
information control and Security system
information control and Security systeminformation control and Security system
information control and Security system
 
information technology and infrastructures choices
information technology and  infrastructures choicesinformation technology and  infrastructures choices
information technology and infrastructures choices
 
ethical issues,social issues
 ethical issues,social issues ethical issues,social issues
ethical issues,social issues
 
managing inforamation system
managing inforamation systemmanaging inforamation system
managing inforamation system
 
• E-commerce, e-business ,e-governance
• E-commerce, e-business ,e-governance• E-commerce, e-business ,e-governance
• E-commerce, e-business ,e-governance
 
IT and innovations
 IT and  innovations  IT and  innovations
IT and innovations
 
organisations and information systems
organisations and  information systemsorganisations and  information systems
organisations and information systems
 
IT stratergy and digital goods
IT stratergy and digital goodsIT stratergy and digital goods
IT stratergy and digital goods
 
Implement Mapreduce with suitable example using MongoDB.
 Implement Mapreduce with suitable example using MongoDB. Implement Mapreduce with suitable example using MongoDB.
Implement Mapreduce with suitable example using MongoDB.
 
Unnamed PL/SQL code block: Use of Control structure and Exception handling i...
 Unnamed PL/SQL code block: Use of Control structure and Exception handling i... Unnamed PL/SQL code block: Use of Control structure and Exception handling i...
Unnamed PL/SQL code block: Use of Control structure and Exception handling i...
 
working with python
working with pythonworking with python
working with python
 
applications and advantages of python
applications and advantages of pythonapplications and advantages of python
applications and advantages of python
 
introduction of python in data science
introduction of python in data scienceintroduction of python in data science
introduction of python in data science
 
tools
toolstools
tools
 
data scientists and their role
data scientists and their roledata scientists and their role
data scientists and their role
 
applications
applicationsapplications
applications
 
statistics techniques to deal with data
statistics techniques to deal with datastatistics techniques to deal with data
statistics techniques to deal with data
 
introduction to data science
introduction to data scienceintroduction to data science
introduction to data science
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 

database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator.

  • 1. Practical No: 3 Problem Statement: Design at least 10 SQL queries for suitable database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator. mysql> use prac3; Database changed mysql> DROP TABLE IF EXISTS emp; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> mysql> CREATE TABLE emp ( -> empno decimal(4,0) NOT NULL, -> ename varchar(10) default NULL, -> job varchar(9) default NULL, -> mgr decimal(4,0) default NULL, -> hiredate date default NULL, -> sal decimal(7,2) default NULL, -> comm decimal(7,2) default NULL, -> deptno decimal(2,0) default NULL -> ); Query OK, 0 rows affected (0.06 sec) mysql> mysql> DROP TABLE IF EXISTS dept; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> mysql> CREATE TABLE dept ( -> deptno decimal(2,0) default NULL, -> dname varchar(14) default NULL, -> loc varchar(13) default NULL -> ); Query OK, 0 rows affected (0.01 sec) mysql> mysql> INSERT INTO emp VALUES ('7369','SMITH','CLERK','7902','1980-12- 17','800.00',NULL,'20'); Query OK, 1 row affected (0.02 sec) mysql> INSERT INTO emp VALUES ('7499','ALLEN','SALESMAN','7698','1981-02- 20','1600.00','300.00','30'); Query OK, 1 row affected (0.04 sec) mysql> INSERT INTO emp VALUES ('7521','WARD','SALESMAN','7698','1981-02- 22','1250.00','500.00','30'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7566','JONES','MANAGER','7839','1981-04- 02','2975.00',NULL,'20'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7654','MARTIN','SALESMAN','7698','1981-09- 28','1250.00','1400.00','30'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7698','BLAKE','MANAGER','7839','1981-05- 01','2850.00',NULL,'30'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7782','CLARK','MANAGER','7839','1981-06- 09','2450.00',NULL,'10'); Query OK, 1 row affected (0.01 sec)
  • 2. mysql> INSERT INTO emp VALUES ('7788','SCOTT','ANALYST','7566','1982-12- 09','3000.00',NULL,'20'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7839','KING','PRESIDENT',NULL,'1981-11- 17','5000.00',NULL,'10'); Query OK, 1 row affected (0.00 sec) mysql> select ename, sal frommysql> select ename, sal from emp where sal between 1000 and 5000; +--------+---------+ | ename | sal | +--------+---------+ | ALLEN | 1600.00 | | WARD | 1250.00 | | JONES | 2975.00 | | MARTIN | 1250.00 | | BLAKE | 2850.00 | | CLARK | 2450.00 | | SCOTT | 3000.00 | | KING | 5000.00 | | TURNER | 1500.00 | | ADAMS | 1100.00 | | FORD | 3000.00 | | MILLER | 1300.00 | +--------+---------+ 12 rows in set (0.00 sec) emp where sal between 1000 and 5000; +--------+---------+ | ename | sal | +--------+---------+ | ALLEN | 1600.00 | | WARD | 1250.00 | | JONES | 2975.00 | | MARTIN | 1250.00 | | BLAKE | 2850.00 | | CLARK | 2450.00 | | SCOTT | 3000.00 | | KING | 5000.00 | | TURNER | 1500.00 | | ADAMS | 1100.00 | | FORD | 3000.00 | | MILLER | 1300.00 | +--------+---------+ 12 rows in set (0.00 sec) mysql> INSERT INTO emp VALUES ('7844','TURNER','SALESMAN','7698','1981-09- 08','1500.00','0.00','30'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7876','ADAMS','CLERK','7788','1983-01- 12','1100.00',NULL,'20'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7900','JAMES','CLERK','7698','1981-12- 03','950.00',NULL,'30'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7902','FORD','ANALYST','7566','1981-12- 03','3000.00',NULL,'20'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO emp VALUES ('7934','MILLER','CLERK','7782','1982-01- 23','1300.00',NULL,'10');
  • 3. Query OK, 1 row affected (0.01 sec) mysql> mysql> INSERT INTO dept VALUES ('10','ACCOUNTING','NEW YORK'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO dept VALUES ('20','RESEARCH','DALLAS'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO dept VALUES ('30','SALES','CHICAGO'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO dept VALUES ('40','OPERATIONS','BOSTON'); Query OK, 1 row affected (0.00 sec) mysql> desc emp; +----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+-------+ | empno | decimal(4,0) | NO | | NULL | | | ename | varchar(10) | YES | | NULL | | | job | varchar(9) | YES | | NULL | | | mgr | decimal(4,0) | YES | | NULL | | | hiredate | date | YES | | NULL | | | sal | decimal(7,2) | YES | | NULL | | | comm | decimal(7,2) | YES | | NULL | | | deptno | decimal(2,0) | YES | | NULL | | +----------+--------------+------+-----+---------+-------+ 8 rows in set (0.00 sec) mysql> select * from emp; +-------+--------+-----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+-----------+------+------------+---------+---------+--------+ | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 | | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | | 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 | | 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 | | 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 | | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 | | 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 | | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 | | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 | | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 | +-------+--------+-----------+------+------------+---------+---------+--------+ 14 rows in set (0.00 sec) mysql> select distinct(job) from emp; +-----------+ | job | +-----------+mysql> select ename, sal from emp where sal between 1000 and 5000; +--------+---------+ | ename | sal | +--------+---------+ | ALLEN | 1600.00 | | WARD | 1250.00 | | JONES | 2975.00 | | MARTIN | 1250.00 | | BLAKE | 2850.00 | | CLARK | 2450.00 |
  • 4. | SCOTT | 3000.00 | | KING | 5000.00 | | TURNER | 1500.00 | | ADAMS | 1100.00 | | FORD | 3000.00 | | MILLER | 1300.00 | +--------+---------+ 12 rows in set (0.00 sec) | CLERK | | SALESMAN | | MANAGER | | ANALYST | | PRESIDENT | +-----------+ 5 rows in set (0.00 sec) mysql> select empno,ename,sal from emp where deptno=20 ; +-------+-------+---------+ | empno | ename | sal | +-------+-------+---------+ | 7369 | SMITH | 800.00 | | 7566 | JONES | 2975.00 | | 7788 | SCOTT | 3000.00 | | 7876 | ADAMS | 1100.00 | | 7902 | FORD | 3000.00 | +-------+-------+---------+ 5 rows in set (0.00 sec) mysql> select empno,ename,sal from emp where deptno like 20 ; +-------+-------+---------+ | empno | ename | sal | +-------+-------+---------+ | 7369 | SMITH | 800.00 | | 7566 | JONES | 2975.00 | | 7788 | SCOTT | 3000.00 | | 7876 | ADAMS | 1100.00 | | 7902 | FORD | 3000.00 | +-------+-------+---------+ 5 rows in set (0.00 sec) mysql> select empno,ename,sal from emp where ename like 'a%' ; +-------+-------+---------+ | empno | ename | sal | +-------+-------+---------+ | 7499 | ALLEN | 1600.00 | | 7876 | ADAMS | 1100.00 | +-------+-------+---------+ 2 rows in set (0.00 sec) mysql> select * from emp where ename like '__N%'; +-------+-------+-----------+------+------------+---------+------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+-------+-----------+------+------------+---------+------+--------+ | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 | +-------+-------+-----------+------+------------+---------+------+--------+ 2 rows in set (0.00 sec) mysql> select deptno as DEPTNO, MAX(sal) as "MAXIMUM SALARY" from emp group by (deptno); +--------+----------------+ | DEPTNO | MAXIMUM SALARY |
  • 5. +--------+----------------+ | 10 | 5000.00 | | 20 | 3000.00 | | 30 | 2850.00 | +--------+----------------+ 3 rows in set (0.00 sec) mysql> select count(sal) from emp where sal=3000; +------------+ | count(sal) | +------------+ | 2 | +------------+ 1 row in set (0.00 sec) mysql> select MAX(sal) from emp; +----------+ | MAX(sal) | +----------+ | 5000.00 | +----------+ 1 row in set (0.00 sec) mysql> select MIN(sal) from emp; +----------+ | MIN(sal) | +----------+ | 800.00 | +----------+ 1 row in set (0.00 sec) mysql> select MIN(sal) least, MAX(sal) max from emp; +--------+---------+ | least | max | +--------+---------+ | 800.00 | 5000.00 | +--------+---------+ 1 row in set (0.00 sec) mysql> select deptno , MIN(sal) "MINIMUM SALARY" from emp group by (deptno); +--------+----------------+ | deptno | MINIMUM SALARY | +--------+----------------+ | 10 | 1300.00 | | 20 | 800.00 | | 30 | 950.00 | +--------+----------------+ 3 rows in set (0.00 sec) mysql> select SUM(sal) totalsal from emp; +----------+ | totalsal | +----------+ | 29025.00 | +----------+ 1 row in set (0.00 sec) mysql> select deptno , SUM(sal) "sal sum" from emp group by (deptno); +--------+----------+ | deptno | sal sum | +--------+----------+ | 10 | 8750.00mysql> select * from t1; +-----+-------+
  • 6. | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) | | 20 | 10875.00 | | 30 | 9400.00 | +--------+----------+ 3 rows in set (0.00 sec) mysql> select deptno , avg(sal) "sal avg" from emp group by (deptno); +--------+-------------+ | deptno | sal avg | +--------+-------------+ | 10 | 2916.666667 | | 20 | 2175.000000 | | 30 | 1566.666667 | +--------+-------------+ 3 rows in set (0.00 sec) mysql> select * from emp where job in('CLERK','PRESIDENT'); +-------+--------+-----------+------+------------+---------+------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+-----------+------+------------+---------+------+--------+ | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 | | 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 | | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 | | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 | +-------+--------+-----------+------+------------+---------+------+--------+ 5 rows in set (0.00 sec) mysql> select * from emp where job not in('CLERK','PRESIDENT'); +-------+--------+----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+----------+------+------------+---------+---------+--------+ | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | | 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 | | 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 | | 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 | | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 | | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 | +-------+--------+----------+------+------------+---------+---------+--------+
  • 7. 9 rows in set (0.00 sec) mysql> select * fromysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) m emp order by comm; +-------+--------+-----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+-----------+------+------------+---------+---------+--------+ | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | NULL | 20 | | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 | | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 | | 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 | | 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 | | 7782 | CLARK | mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2;
  • 8. +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 | | 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 | | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 | | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 | | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | +-------+--------+- mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) | 5 | pati | +-----+-------+
  • 9. 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) ----------+------+------------+---------+---------+--------+ 14 rows in set (0.00 sec) mysql> select * from emp where comm <> 'NULL'; +-------+--------+----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+----------+------+------------+---------+---------+--------+ | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | +-------+--------+----------+------+------------+---------+---------+--------+ 3 rows in set, 1 warning (0.00 sec) mysql> select * from emp where comm <> 'NULL' order by comm desc; +-------+--------+----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+----------+------+------------+---------+---------+--------+ | 7654 | MARTIN | mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec)
  • 10. mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) sec) SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | +-------+--------+----------+------+------------+---------+---------+--------+ 3 rows in set, 1 warning (0.00 sec) mysql> select ename, sal from emp where sal between 1000 and 5000; +--------+---------+mysql> select ename, sal from emp where sal between 1000 and 5000; +--------+---------+ | ename | sal | +--------+---------+ | ALLEN | 1600.00 | | WARD | 1250.00 mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+
  • 11. | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) | | JONES | 2975.00 | | MARTIN | 1250.00 mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) | | BLAKE | 2850.00 | | CLARK | 2450.00 | | SCOTT | 3000.00 | | KING | 5000.00 |
  • 12. | TURNER | 1500.00 | | ADAMS | 1100.00 | | FORD | 3000.00 | | MILLER | 1300.00 | +--------+---------+ 12 rows in set (0.00 sec) | ename | sal | +--------+---------+ | ALLEN | 1600.00 | | WARD | 1250.00 | | JONES | 2975.00 | | MARTIN | 1250.00 | | BLAKE | 2850.00 | | CLARK | 2450.00 | | SCOTT | 3000.00 | | KING | 5000.00 | | TURNER | 1500.00 | | ADAMS | 1100.00 | | FORD | 3000.00 | | MILLER | 1300.00 | +--------+---------+ 12 rows in set (0.00 sec) mysql> select empno,ename,job,comm,sal from emp where sal>=1000 and sal<=3000; +-------+--------+----------+---------+---------+ | empno | ename | job | comm | sal | +-------+--------+----------+---------+---------+ | 7499 | ALLEN | SALESMAN | 300.00 | 1600.00 | | 7521 | WARD | SALESMAN | 500.00 | 1250.00 | | 7566 | JONES | MANAGER | NULL | 2975.00 | | 7654 | MARTIN | SALESMAN | 1400.00 | 1250.00 | | 7698 | BLAKE | MANAGER | NULL | 2850.00 | | 7782 | CLARK | MANAGER | NULL | 2450.00 | | 7788 | SCOTT | ANALYST | NULL | 3000.00 | | 7844 | TURNER | SALESMAN | 0.00 | 1500.00 | | 7876 | ADAMS | CLERK | NULL | 1100.00 | | 7902 | FORD | ANALYST | NULL | 3000.00 | | 7934 | MILLER | CLERK | NULL | 1300.00 | +-------+--------+----------+---------+---------+ 11 rows in set (0.00 sec) mysql> select empno,ename,job,comm,sal from emp where sal>=1000 or sal<=3000; +-------+--------+-----------+---------+---------+ | empno | ename | job | comm | sal | +-------+--------+-----------+---------+---------+ | 7369 | SMITH | CLERK | NULL | 800.00 | | 7499 | ALLEN | SALESMAN | 300.00 | 1600.00 | | 7521 | WARD | SALESMAN | 500.00 | 1250.00 | | 7566 | JONES | MANAGER | NULL | 2975.00 | | 7654 | MARTIN | SALESMAN | 1400.00 | 1250.00 | | 7698 | BLAKE | MANAGER | NULL | 2850.00 | | 7782 | CLARK | MANAGER | NULL | 2450.00 | | 7788 | SCOTT | ANALYST | NULL | 3000.00 | | 7839 | KING | PRESIDENT | NULL | 5000.00 | | 7844 | TURNER | SALESMAN | 0.00 | 1500.00 | | 7876 | ADAMS | CLERK | NULL | 1100.00 | | 7900 | JAMES | CLERK | NULL | 950.00 | | 7902 | FORD | ANALYST | NULL | 3000.00 |
  • 13. | 7934 | MILLER | CLERK | NULL | 1300.00 | +-------+--------+-----------+---------+---------+ 14 rows in set (0.00 sec) mysql> select empno,ename,job,comm,sal from emp where not sal=3000; +-------+--------+-----------+---------+---------+ | empno | ename | job | comm | sal | +-------+--------+-----------+---------+---------+ | 7369 | SMITH | CLERK | NULL | 800.00 | | 7499 | ALLEN | SALESMAN | 300.00 | 1600.00 | | 7521 | WARD | SALESMAN | 500.00 | 1250.00 | | 7566 | JONES | MANAGER | NULL | 2975.00 | | 7654 | MARTIN | SALESMAN | 1400.00 | 1250.00 | | 7698 | BLAKE | MANAGER | NULL | 2850.00 | | 7782 | CLARK | MANAGER | NULL | 2450.00 | | 7839 | KING | PRESIDENT | NULL | 5000.00 | | 7844 | TURNER | SALESMAN | 0.00 | 1500.00 | | 7876 | ADAMS | CLERK | NULL | 1100.00 | | 7900 | JAMES | CLERK | NULL | 950.00 | | 7934 | MILLER | CLERK | NULL | 1300.00 | +-------+--------+-----------+---------+---------+ 12 rows in set (0.00 sec) mysql> update emp set comm=520 where empno=7369; Query OK, 1 row affected (0.37 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from emp; +-------+--------+-----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+-----------+------+------------+---------+---------+--------+ | 7369 | SMITH | CLERK | 7902 | 1980-12-17 | 800.00 | 520.00 | 20 | | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | | 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 | | 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 | | 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 | | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 | | 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 | | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 | | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 | | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 | +-------+--------+-----------+------+------------+---------+---------+--------+ 14 rows in set (0.00 sec) mysql> delete from emp where empno=7369; Query OK, 1 row affected (0.01 sec) mysql> select * from emp; +-------+--------+-----------+------+------------+---------+---------+--------+ | empno | ename | job | mgr | hiredate | sal | comm | deptno | +-------+--------+-----------+------+------------+---------+---------+--------+ | 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.00 | 300.00 | 30 | | 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.00 | 500.00 | 30 | | 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.00 | NULL | 20 | | 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.00 | 1400.00 | 30 | | 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.00 | NULL | 30 | | 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.00 | NULL | 10 | | 7788 | SCOTT | ANALYST | 7566 | 1982-12-09 | 3000.00 | NULL | 20 | | 7839 | KING | PRESIDENT | NULL | 1981-11-17 | 5000.00 | NULL | 10 |
  • 14. | 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.00 | 0.00 | 30 | | 7876 | ADAMS | CLERK | 7788 | 1983-01-12 | 1100.00 | NULL | 20 | | 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.00 | NULL | 30 | | 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.00 | NULL | 20 | | 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.00 | NULL | 10 | +-------+--------+-----------+------+------------+---------+---------+--------+ 13 rows in set (0.00 sec) ________________________________________________________________________________ _______ mysql> select * from t1; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 5 rows in set (0.00 sec) mysql> select * from t1 union select * from t2; +-----+-------+ | Rno | Name | +-----+-------+ | 1 | amit | | 2 | rohan | | 3 | rahul | | 4 | Nayan | | 5 | pati | | 6 | xyz | | 7 | pqr | +-----+-------+ 7 rows in set (0.00 sec) mysql> select distinct(Rno) as "Common RollNo" from t1 inner join t2 using(Rno); +---------------+ | Common RollNo | +---------------+ | 3 | | 4 | | 5 | +---------------+ 3 rows in set (0.00 sec)