Informatics Practices ass5
Informatics Practices ass5
Q1.
mysql> create table Stock(Itemno char(3) Primary key, Itemname varchar(50) not
null, Brand varchar(10), Qty int, Unitprice float(5,2), Stockdate date);
Query OK, 0 rows affected, 1 warning (0.13 sec)
mysql> insert into stock values('S05', 'Ball pen 0.5', 'Luxor', 100, 16,
'2021-03-31');
Query OK, 1 row affected (0.14 sec)
mysql> insert into stock values('S03', 'Ball pen 0.25', 'Reynolds', 150,
20.05, '2022-01-01');
Query OK, 1 row affected (0.02 sec)
mysql> insert into stock values('S02', 'Gell pen premium', 'Luxor', 125,
14.42, '2022-02-14');
Query OK, 1 row affected (0.01 sec)
mysql> insert into stock values('S06', 'Gell pen clasic', 'Pentel', 200,
22.75, '2022-01-09');
Query OK, 1 row affected (0.01 sec)
mysql> insert into stock values('S01', 'Eraser small', 'null', 210, null,
null);
Query OK, 1 row affected (0.01 sec)
mysql> insert into stock values('S04', 'Eraser big', 'Apsara', 60, 10, '2020-
12-12');
Query OK, 1 row affected (0.02 sec)
mysql> select itemname, qty from stock where itemname like '%Pen%';
+------------------+------+
| itemname | qty |
+------------------+------+
| Gell pen premium | 125 |
| Ball pen 0.25 | 150 |
| Ball pen 0.5 | 100 |
| Gell pen clasic | 200 |
+------------------+------+
4 rows in set (0.01 sec)
mysql> select * from stock where unitprice between 15 and 20;
+--------+--------------+-------+------+-----------+------------+
| Itemno | Itemname | Brand | Qty | Unitprice | Stockdate |
+--------+--------------+-------+------+-----------+------------+
| S05 | Ball pen 0.5 | Luxor | 100 | 16.00 | 2021-03-31 |
+--------+--------------+-------+------+-----------+------------+
1 row in set (0.12 sec)
Q2.
mysql> create table Employee(Empno char(4) Primary key, Ename varchar(20), Job
varchar(15), Hiredate date, Sal int, Comm int, Deptno int);
Query OK, 0 rows affected (0.27 sec)
mysql> select ename, sal, deptno from employee where comm is null;
+----------+-------+--------+
| ename | sal | deptno |
+----------+-------+--------+
| Smith | 8000 | 20 |
| Momin | 25000 | 10 |
| Bina | 30000 | 20 |
| Shivansh | 50000 | 10 |
+----------+-------+--------+
4 rows in set (0.02 sec)
mysql> select ename, sal, comm from employee where comm is not null;
+-----------+-------+------+
| ename | sal | comm |
+-----------+-------+------+
| Anya | 16000 | 500 |
| Mahadeven | 10000 | 300 |
| Scott | 12000 | 1200 |
+-----------+-------+------+
3 rows in set (0.03 sec)
mysql> select * from employee where sal between 20000 and 50000;
+-------+----------+-----------+------------+-------+------+--------+--------+
| Empno | ename | Job | Hiredate | Sal | Comm | Deptno | Bonues |
+-------+----------+-----------+------------+-------+------+--------+--------+
| 8566 | Momin | Manager | 1991-04-02 | 25000 | NULL | 10 | 700.00 |
| 8654 | Bina | Analyst | 1992-12-09 | 30000 | NULL | 20 | 700.00 |
| 8698 | Shivansh | President | 1991-11-18 | 50000 | NULL | 10 | 700.00 |
+-------+----------+-----------+------------+-------+------+--------+--------+
3 rows in set (0.05 sec)
mysql> Update employee set sal = 10000, comm = 200 where empno=8369;
Query OK, 1 row affected (0.09 sec)
Rows matched: 1 Changed: 1 Warnings: 0