SQL PROJECT 1
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.41 MySQL Community Server - GPL
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database company;
ERROR 1007 (HY000): Can't create database 'company'; database exists
mysql> use company;
Database changed
mysql> create table emp(Empno int(5), Ename varchar(30), Job varchar(20), MGR int(5),
Hiredate date, Sal float(10,2), COMM int(5), DEPTNO int(4) );
Query OK, 0 rows affected, 5 warnings (3.88 sec)
mysql> insert into emp values(7369, 'Sumit Sharma', 'Clerk', 7902, '1990-12-17', 12800,
null, 20);
Query OK, 1 row affected (0.51 sec)
mysql> select * from emp;
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7369 Sumit Clerk 7902 1990- 12800.0 NULL 20
Sharma 12-17 0
1 row in set (0.03 sec)
mysql> insert into emp values(7499, 'Ashok Singhal', 'Salesman', 7698, '1991-02-20',
13600, 1300, 30);
Query OK, 1 row affected (0.30 sec)
mysql> insert into emp values(7521, 'Sumit Avasti', 'Salesman', 7698, '1991-02-22', 15250,
1500, 30);
Query OK, 1 row affected (1.36 sec)
mysql> insert into emp values(7566, 'Jyoti Lamba', 'Manager', 7839, '1991-04-02', 14975,
null, 20);
Query OK, 1 row affected (0.64 sec)
mysql> insert into emp values(7654, 'Martin S', 'Salesman', 7689, '1991-09-28', 16250,
2400, 30);
Query OK, 1 row affected (0.30 sec)
mysql> insert into emp values(7698, 'Binod Goel', 'Manager', 7839, '1991-05-01', 15850,
null, 30);
Query OK, 1 row affected (0.67 sec)
mysql> insert into emp values(7782, 'Chetan Gupta', 'Manager', 7839, '1991-06-09', 12450,
null, 10);
Query OK, 1 row affected (0.21 sec)
mysql> insert into emp values(7788, 'Sudhir Rawat', 'Analyst', 7566, '1991-04-19', 15000,
null, 20);
Query OK, 1 row affected (0.39 sec)
mysql> insert into emp values(7839, 'Kavita Sharma', 'President', null, '1991-11-17', 1500,
null, 10);
Query OK, 1 row affected (0.27 sec)
mysql> insert into emp values(7844, 'Tushar Tiwari', 'Salesman', 7698, '1991-09-08',
14500, 0, 30);
Query OK, 1 row affected (0.46 sec)
mysql> insert into emp values(7876, 'Anand Rathi', 'Clerk', 7788, '1997-05-23', 16100, null,
20);
Query OK, 1 row affected (0.29 sec)
mysql> insert into emp values(7900, 'Jagdeep Rana', 'Clerk', 7698, '1991-12-03', 14950,
null, 30);
Query OK, 1 row affected (0.41 sec)
mysql> insert into emp values(7902, 'Sumit Vats', 'Analyst', 7566, '1991-12-03', 13500,
3600, 20);
Query OK, 1 row affected (0.38 sec)
mysql> insert into emp values(7934, 'Manoj Kaushik', 'Clerk', 7782, '1991-01-23', 15300,
null, 10);
Query OK, 1 row affected (1.32 sec)
mysql> select * from emp;
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7369 Sumit Clerk 7902 1990- 12800.0 NULL 20
Sharma 12-17 0
7499 Ashok Salesma 7698 1991- 13600.0 1300 30
Singhal n 02-20 0
7521 Sumit Salesma 7698 1991- 15250.0 1500 30
Avasti n 02-22 0
7566 Jyoti Manager 7839 1991- 14975.0 NULL 20
Lamba 04-02 0
7654 Martin S Salesma 7689 1991- 16250.0 2400 30
n 09-28 0
7698 Binod Manager 7839 1991- 15850.0 NULL 30
Goel 05-01 0
7782 Chetan Manager 7839 1991- 12450.0 NULL 10
Gupta 06-09 0
7788 Sudhir Analyst 7566 1991- 15000.0 NULL 20
Rawat 04-19 0
7839 Kavita Presiden NULL 1991- 1500.00 NULL 10
Sharma t 11-17
7844 Tushar Salesma 7698 1991- 14500.0 0 30
Tiwari n 09-08 0
7876 Anand Clerk 7788 1997- 16100.0 NULL 20
Rathi 05-23 0
7900 Jagdeep Clerk 7698 1991- 14950.0 NULL 30
Rana 12-03 0
7902 Sumit Analyst 7566 1991- 13500.0 3600 20
Vats 12-03 0
7934 Manoj Clerk 7782 1991- 15300.0 NULL 10
Kaushik 01-23 0
14 rows in set (0.00 sec)
mysql> select empno, ename, sal from emp;
empno ename sal
7369 Sumit Sharma 12800.00
7499 Ashok Singhal 13600.00
7521 Sumit Avasti 15250.00
7566 Jyoti Lamba 14975.00
7654 Martin S 16250.00
7698 Binod Goel 15850.00
7782 Chetan Gupta 12450.00
7788 Sudhir Rawat 15000.00
7839 Kavita Sharma 1500.00
7844 Tushar Tiwari 14500.00
7876 Anand Rathi 16100.00
7900 Jagdeep Rana 14950.00
7902 Sumit Vats 13500.00
7934 Manoj Kaushik 15300.00
14 rows in set (0.00 sec)
mysql> select empno, ename, 10/100 *sal from emp;
empno ename 10/100 *sal
7369 Sumit Sharma 1280.0000
7499 Ashok Singhal 1360.0000
7521 Sumit Avasti 1525.0000
7566 Jyoti Lamba 1497.5000
7654 Martin S 1625.0000
7698 Binod Goel 1585.0000
7782 Chetan Gupta 1245.0000
7788 Sudhir Rawat 1500.0000
7839 Kavita Sharma 150.0000
7844 Tushar Tiwari 1450.0000
7876 Anand Rathi 1610.0000
7900 Jagdeep Rana 1495.0000
7902 Sumit Vats 1350.0000
7934 Manoj Kaushik 1530.0000
14 rows in set (0.06 sec)
mysql> select * from emp where sal <=15000;
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7369 Sumit Clerk 7902 1990- 12800.0 NULL 20
Sharma 12-17 0
7499 Ashok Salesma 7698 1991- 13600.0 1300 30
Singhal n 02-20 0
7566 Jyoti Manager 7839 1991- 14975.0 NULL 20
Lamba 04-02 0
7782 Chetan Manager 7839 1991- 12450.0 NULL 10
Gupta 06-09 0
7788 Sudhir Analyst 7566 1991- 15000.0 NULL 20
Rawat 04-19 0
7839 Kavita Presiden NULL 1991- 1500.00 NULL 10
Sharma t 11-17
7844 Tushar Salesma 7698 1991- 14500.0 0 30
Tiwari n 09-08 0
7900 Jagdeep Clerk 7698 1991- 14950.0 NULL 30
Rana 12-03 0
7902 Sumit Analyst 7566 1991- 13500.0 3600 20
Vats 12-03 0
9 rows in set (0.03 sec)
mysql> select ename, sal >=20000 from emp;
ename sal >=20000
Sumit Sharma 0
Ashok Singhal 0
Sumit Avasti 0
Jyoti Lamba 0
Martin S 0
Binod Goel 0
Chetan Gupta 0
Sudhir Rawat 0
Kavita Sharma 0
Tushar Tiwari 0
Anand Rathi 0
Jagdeep Rana 0
Sumit Vats 0
Manoj Kaushik 0
14 rows in set (0.00 sec)
mysql> select empno, ename from emp where deptno = 30 and sal > 15000;
empno ename
7521 Sumit Avasti
7654 Martin S
7698 Binod Goel
3 rows in set (0.00 sec)
mysql> select * from emp where ename in ('Sumit Vats', 'Chetan Gupta');
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7782 Chetan Manager 7839 1991- 12450.0 NULL 10
Gupta 06-09 0
7902 Sumit Analyst 7566 1991- 13500.0 3600 20
Vats 12-03 0
2 rows in set (0.00 sec)
mysql> select * from emp where ename!= 'jagdeep rana';
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7369 Sumit Clerk 7902 1990- 12800.0 NULL 20
Sharma 12-17 0
7499 Ashok Salesma 7698 1991- 13600.0 1300 30
Singhal n 02-20 0
7521 Sumit Salesma 7698 1991- 15250.0 1500 30
Avasti n 02-22 0
7566 Jyoti Manager 7839 1991- 14975.0 NULL 20
Lamba 04-02 0
7654 Martin S Salesma 7689 1991- 16250.0 2400 30
n 09-28 0
7698 Binod Manager 7839 1991- 15850.0 NULL 30
Goel 05-01 0
7782 Chetan Manager 7839 1991- 12450.0 NULL 10
Gupta 06-09 0
7788 Sudhir Analyst 7566 1991- 15000.0 NULL 20
Rawat 04-19 0
7839 Kavita Presiden NULL 1991- 1500.00 NULL 10
Sharma t 11-17
7844 Tushar Salesma 7698 1991- 14500.0 0 30
Tiwari n 09-08 0
7876 Anand Clerk 7788 1997- 16100.0 NULL 20
Rathi 05-23 0
7902 Sumit Analyst 7566 1991- 13500.0 3600 20
Vats 12-03 0
7934 Manoj Clerk 7782 1991- 15300.0 NULL 10
Kaushik 01-23 0
13 rows in set (0.00 sec)
mysql> select * from emp where ename in ('Sumit Vats', 'Chetan Gupta');
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7782 Chetan Manager 7839 1991- 12450.0 NULL 10
Gupta 06-09 0
7902 Sumit Analyst 7566 1991- 13500.0 3600 20
Vats 12-03 0
2 rows in set (0.00 sec)
mysql> select * from emp where comm is null;
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7369 Sumit Clerk 7902 1990- 12800.0 NULL 20
Sharma 12-17 0
7566 Jyoti Manager 7839 1991- 14975.0 NULL 20
Lamba 04-02 0
7698 Binod Manager 7839 1991- 15850.0 NULL 30
Goel 05-01 0
7782 Chetan Manager 7839 1991- 12450.0 NULL 10
Gupta 06-09 0
7788 Sudhir Analyst 7566 1991- 15000.0 NULL 20
Rawat 04-19 0
7839 Kavita Presiden NULL 1991- 1500.00 NULL 10
Sharma t 11-17
7876 Anand Clerk 7788 1997- 16100.0 NULL 20
Rathi 05-23 0
7900 Jagdeep Clerk 7698 1991- 14950.0 NULL 30
Rana 12-03 0
7934 Manoj Clerk 7782 1991- 15300.0 NULL 10
Kaushik 01-23 0
9 rows in set (0.02 sec)
mysql> select distinct deptno from emo;
ERROR 1146 (42S02): Table 'company.emo' doesn't exist
mysql> select distinct deptno from emp;
deptno
20
30
10
3 rows in set (0.20 sec)
mysql> select empno, ename, sal from emp where sal between 15000 and 20000;
empno ename sal
7521 Sumit Avasti 15250.00
7654 Martin S 16250.00
7698 Binod Goel 15850.00
7788 Sudhir Rawat 15000.00
7876 Anand Rathi 16100.00
7934 Manoj Kaushik 15300.00
6 rows in set (0.00 sec)
mysql> select empno, ename, job from emp where empno in (7876, 7839, 7788, 7566);
empno ename job
7566 Jyoti Lamba Manager
7788 Sudhir Rawat Analyst
7839 Kavita Sharma President
7876 Anand Rathi Clerk
4 rows in set (0.00 sec)
mysql> select empno, ename from emp where ename like 'S%';
empno ename
7369 Sumit Sharma
7521 Sumit Avasti
7788 Sudhir Rawat
7902 Sumit Vats
4 rows in set (0.03 sec)
mysql> select empno, ename, sal from emp where ename like '_a%';
empno ename sal
7654 Martin S 16250.00
7839 Kavita Sharma 1500.00
7900 Jagdeep Rana 14950.00
7934 Manoj Kaushik 15300.00
4 rows in set (0.00 sec)
mysql> select empno, ename, sal from emp where ename like '%n_';
empno ename sal
7900 Jagdeep Rana 14950.00
1 row in set (0.00 sec)
mysql> select empno, ename, sal from emp where ename like'%a';
empno ename sal
7369 Sumit Sharma 12800.00
7566 Jyoti Lamba 14975.00
7782 Chetan Gupta 12450.00
7839 Kavita Sharma 1500.00
7900 Jagdeep Rana 14950.00
5 rows in set (0.00 sec)
mysql> select empno, ename, sal from emp where ename like '%i%';
empno ename sal
7369 Sumit Sharma 12800.00
7499 Ashok Singhal 13600.00
7521 Sumit Avasti 15250.00
7566 Jyoti Lamba 14975.00
7654 Martin S 16250.00
7698 Binod Goel 15850.00
7788 Sudhir Rawat 15000.00
7839 Kavita Sharma 1500.00
7844 Tushar Tiwari 14500.00
7876 Anand Rathi 16100.00
7902 Sumit Vats 13500.00
7934 Manoj Kaushik 15300.00
12 rows in set (0.09 sec)
mysql> select empno, ename where empno!= '7788, 7839, 7900';
ERROR 1054 (42S22): Unknown column 'empno' in 'field list'
mysql> select empno, ename from emp where empno not in (7788, 7839, 7900);
empno ename
7369 Sumit Sharma
7499 Ashok Singhal
7521 Sumit Avasti
7566 Jyoti Lamba
7654 Martin S
7698 Binod Goel
7782 Chetan Gupta
7844 Tushar Tiwari
7876 Anand Rathi
7902 Sumit Vats
7934 Manoj Kaushik
11 rows in set (0.00 sec)
mysql> select empno, ename from emp where sal not between 15000 and 20000;
empno ename
7369 Sumit Sharma
7499 Ashok Singhal
7566 Jyoti Lamba
7782 Chetan Gupta
7839 Kavita Sharma
7844 Tushar Tiwari
7900 Jagdeep Rana
7902 Sumit Vats
8 rows in set (0.00 sec)
mysql> select empno, ename from emp where comm not null;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'null' at line 1
mysql> select empno, ename from emp where comm is not null;
empno ename
7499 Ashok Singhal
7521 Sumit Avasti
7654 Martin S
7844 Tushar Tiwari
7902 Sumit Vats
5 rows in set (0.00 sec)
mysql> select empno, ename, sal *12 as annual_sal from emp;
empno ename annual_sal
7369 Sumit Sharma 153600.00
7499 Ashok Singhal 163200.00
7521 Sumit Avasti 183000.00
7566 Jyoti Lamba 179700.00
7654 Martin S 195000.00
7698 Binod Goel 190200.00
7782 Chetan Gupta 149400.00
7788 Sudhir Rawat 180000.00
7839 Kavita Sharma 18000.00
7844 Tushar Tiwari 174000.00
7876 Anand Rathi 193200.00
7900 Jagdeep Rana 179400.00
7902 Sumit Vats 162000.00
7934 Manoj Kaushik 183600.00
14 rows in set (0.00 sec)
mysql> UPDATE emp set sal = sal + 500 where sal < 15000;
Query OK, 8 rows affected (0.39 sec)
Rows matched: 8 Changed: 8 Warnings: 0
mysql> select * from emp;
Empno Ename Job MGR Hiredate Sal COMM DEPTNO
7369 Sumit Clerk 7902 1990- 13300.0 NULL 20
Sharma 12-17 0
7499 Ashok Salesma 7698 1991- 14100.0 1300 30
Singhal n 02-20 0
7521 Sumit Salesma 7698 1991- 15250.0 1500 30
Avasti n 02-22 0
7566 Jyoti Manager 7839 1991- 15475.0 NULL 20
Lamba 04-02 0
7654 Martin S Salesma 7689 1991- 16250.0 2400 30
n 09-28 0
7698 Binod Manager 7839 1991- 15850.0 NULL 30
Goel 05-01 0
7782 Chetan Manager 7839 1991- 12950.0 NULL 10
Gupta 06-09 0
7788 Sudhir Analyst 7566 1991- 15000.0 NULL 20
Rawat 04-19 0
7839 Kavita Presiden NULL 1991- 2000.00 NULL 10
Sharma t 11-17
7844 Tushar Salesma 7698 1991- 15000.0 0 30
Tiwari n 09-08 0
7876 Anand Clerk 7788 1997- 16100.0 NULL 20
Rathi 05-23 0
7900 Jagdeep Clerk 7698 1991- 15450.0 NULL 30
Rana 12-03 0
7902 Sumit Analyst 7566 1991- 14000.0 3600 20
Vats 12-03 0
7934 Manoj Clerk 7782 1991- 15300.0 NULL 10
Kaushik 01-23 0
14 rows in set (0.00 sec)