0% found this document useful (0 votes)
18 views2 pages

Q 5

A database named 'compsci' was created. A table named 'MOV' was then created within this database to store movie data with fields for number, title, type, rating, stars, quantity, and price. Six movies were inserted into this table with data for each field. Queries were then run to select data from this table based on certain criteria like price or quantity. Calculated fields were also selected like current value and replacement value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Q 5

A database named 'compsci' was created. A table named 'MOV' was then created within this database to store movie data with fields for number, title, type, rating, stars, quantity, and price. Six movies were inserted into this table with data for each field. Queries were then run to select data from this table based on certain criteria like price or quantity. Calculated fields were also selected like current value and replacement value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

mysql> create database compsci;

Query OK, 1 row affected (0.18 sec)

mysql> use compsci;


Database changed
mysql> create table MOV(
-> No int primary key,
-> Title varchar(255),
-> Type varchar(255),
-> Rating varchar(255),
-> Stars int,
-> Qty int,
-> Price int
-> );
Query OK, 0 rows affected (1.31 sec)

mysql>
mysql>
mysql>
mysql>
mysql>
mysql> insert into MOV(no,title,type,rating,stars,qty,price)
-> values(10,"abc","xyz","14+",5,15,15),
-> (1,"abc","xyz","14+",5,15,15),
-> (2,"xbc","ayz","16+",4.5,10,25),
-> (3,"zbc","cyz","15+",3,19,35),
-> (4,"rbc","eyz","11+",4.5,25,20),
-> (5,"jbc","dyz","14+",5,15,10);
Query OK, 6 rows affected (0.14 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> select * from mov;


+----+-------+------+--------+-------+------+-------+
| No | Title | Type | Rating | Stars | Qty | Price |
+----+-------+------+--------+-------+------+-------+
| 1 | abc | xyz | 14+ | 5 | 15 | 15 |
| 2 | xbc | ayz | 16+ | 5 | 10 | 25 |
| 3 | zbc | cyz | 15+ | 3 | 19 | 35 |
| 4 | rbc | eyz | 11+ | 5 | 25 | 20 |
| 5 | jbc | dyz | 14+ | 5 | 15 | 10 |
| 10 | abc | xyz | 14+ | 5 | 15 | 15 |
+----+-------+------+--------+-------+------+-------+
6 rows in set (0.00 sec)

mysql> select * from mov where price>20 order by price;


+----+-------+------+--------+-------+------+-------+
| No | Title | Type | Rating | Stars | Qty | Price |
+----+-------+------+--------+-------+------+-------+
| 2 | xbc | ayz | 16+ | 5 | 10 | 25 |
| 3 | zbc | cyz | 15+ | 3 | 19 | 35 |
+----+-------+------+--------+-------+------+-------+
2 rows in set (0.00 sec)

mysql> select * from mov order by qty desc;


+----+-------+------+--------+-------+------+-------+
| No | Title | Type | Rating | Stars | Qty | Price |
+----+-------+------+--------+-------+------+-------+
| 4 | rbc | eyz | 11+ | 5 | 25 | 20 |
| 3 | zbc | cyz | 15+ | 3 | 19 | 35 |
| 1 | abc | xyz | 14+ | 5 | 15 | 15 |
| 5 | jbc | dyz | 14+ | 5 | 15 | 10 |
| 10 | abc | xyz | 14+ | 5 | 15 | 15 |
| 2 | xbc | ayz | 16+ | 5 | 10 | 25 |
+----+-------+------+--------+-------+------+-------+
6 rows in set (0.00 sec)

mysql> select no,qty*price as current_value,qty*price*0.5 as replacement_value from


mov;
+----+---------------+-------------------+
| no | current_value | replacement_value |
+----+---------------+-------------------+
| 1 | 225 | 112.5 |
| 2 | 250 | 125.0 |
| 3 | 665 | 332.5 |
| 4 | 500 | 250.0 |
| 5 | 150 | 75.0 |
| 10 | 225 | 112.5 |
+----+---------------+-------------------+
6 rows in set (0.00 sec)

You might also like