0% found this document useful (0 votes)
6 views

Mysql

Uploaded by

aka711964
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Mysql

Uploaded by

aka711964
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

mysql>use 12a2024;

Database changed

mysql> create table computer(ProdID char(4),Prod_Name char(15),Price int,Company char(15),Type


char(15));

Query OK, 0 rows affected (0.03 sec)

mysql> insert into computer values('P004','Mouse',200,'Logitech','Input');

Query OK, 1 row affected (0.01 sec)

mysql> select* from computer;

+--------+-----------------+-------+----------+--------+

| ProdID | Prod_Name | Price | Company | Type |

+--------+-----------------+-------+----------+--------+

| P001 | Mouse | 200 | Logitech | Input |

| P002 | Laser Printer | 4000 | Canon | Output |

| P003 | Keyboard | 500 | Logitech | Input |

| P004 | Joystick | 1000 | I-pod | Input |

| P005 | Speaker | 1200 | Creative | Output |

| P006 | Dustjet Printer | 4300 | Canon | Output |

+--------+-----------------+-------+----------+--------+

6 rows in set (0.00 sec)

mysql> create table sales(ProdID char(4),Qty_sold int,Quarter int);

Query OK, 0 rows affected (0.03 sec)

mysql> insert into sales values('POO2',4,1);

Query OK, 1 row affected (0.01 sec)

mysql> select min(Price),max(Price) from computer;

+------------+------------+

| min(Price) | max(Price) |

+------------+------------+

| 200 | 4300 |

+------------+------------+

1 row in set (0.00 sec)


mysql> select Company,count(*) from Computer group by Company having count(Company)>1;

+----------+----------+

| Company | count(*) |

+----------+----------+

| Logitech | 2|

| Canon | 2|

+----------+----------+

2 rows in set (0.00 sec)

mysql> select Prod_Name,Company,Quarter from computer,sales where


computer.ProdID=sales.ProdID;

+---------------+----------+---------+

| Prod_Name | Company | Quarter |

+---------------+----------+---------+

| Mouse | Logitech | 2|

| Laser Printer | Canon | 1|

| Keyboard | Logitech | 2|

| Joystick | I-pod | 1|

+---------------+----------+---------+

4 rows in set (0.00 sec)

mysql> select Prod_Name,Qty_sold from computer,sales where computer.ProdID=sales.ProdID;

+---------------+----------+

| Prod_Name | Qty_sold |

+---------------+----------+

| Mouse | 3|

| Laser Printer | 4|

| Keyboard | 2|

| Joystick | 2|

+---------------+----------+

4 rows in set (0.00 sec)

mysql>

You might also like