PRJ

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

Microsoft Windows [Version 10.0.18362.

535]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\WP>mysql -u root -padmidnd


Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

C:\Users\WP>mysql -u root -padmin


Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| carreview |
| company |
| cosmetic |
| cosmetics |
| mysql |
| performance_schema |
| stationary |
| students |
| test |
| training |
| university |
+--------------------+
12 rows in set (0.13 sec)

mysql> use cosmetics;


Database changed
mysql> show tales;
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 'tales'
at line 1
mysql> show tables;
+---------------------+
| Tables_in_cosmetics |
+---------------------+
| customer |
| employee |
| makeup |
| owner |
| sale |
| skincare |
+---------------------+
6 rows in set (0.00 sec)
mysql> select * from customer;
+------+-------------+---------------------+-------------+--------------
+------------+
| c_id | cName | email | phNo | address | password
|
+------+-------------+---------------------+-------------+--------------
+------------+
| c-1 | Khant Khant | [email protected] | 9356873968 | Pyay | Khant890
|
| c-10 | Phuu Phuu | [email protected] | 99937563335 | Magway |
Phuuzin456 |
| c-2 | Khin Khin | [email protected] | 9245259788 | Yangon | Khin490
|
| c-3 | Hsu Hsu | [email protected] | 9877359278 | Pyin Oo Lwin | Hsu560
|
| c-4 | Han Ni | [email protected] | 9457628996 | Pyay | Hanni093
|
| c-5 | Poe Poe | [email protected] | 9896567323 | Sinde | Poeei564
|
| c-6 | Kyaw Naing | [email protected] | 96578295789 | Mandalay | Kyaw375
|
| c-7 | Rose | [email protected] | 9936672896 | Nay Pyi Taw | Rose456
|
| c-8 | Yadanar | [email protected] | 98789723589 | Pyay |
Yadanar345 |
| c-9 | Marlar | [email protected] | 9658927994 | Yangon | Marlar09
|
+------+-------------+---------------------+-------------+--------------
+------------+
10 rows in set (0.04 sec)

mysql> select * from makeup;


+------+------------+----------+--------------+----------+------+
| m_id | item | brand_id | brand | price | qty |
+------+------------+----------+--------------+----------+------+
| m-1 | Foundation | b-1 | Chanel | 40000.00 | 10 |
| m-10 | Eyeliner | b-10 | Healthy Shop | 40000.00 | 40 |
| m-2 | lipstick | b-2 | Wet n Wild | 40000.00 | 20 |
| m-3 | Concealer | b-3 | Essence | 34000.00 | 40 |
| m-4 | Eyebrows | b-4 | Loreal Paris | 14000.00 | 40 |
| m-5 | Pallete | b-5 | Sephora | 50000.00 | 14 |
| m-6 | Bronzer | b-6 | Maybelline | 20000.00 | 24 |
| m-7 | Foundation | b-7 | Dior | 80000.00 | 23 |
| m-8 | Emultion | b-8 | Dabo | 60000.00 | 10 |
| m-9 | Lipstick | b-9 | Mac | 74000.00 | 10 |
+------+------------+----------+--------------+----------+------+
10 rows in set (0.00 sec)

mysql> select * from skincare;


+-------+-------------+----------+--------------+----------+------+
| sk_id | item | brand_id | brand | price | qty |
+-------+-------------+----------+--------------+----------+------+
| s-1 | Day Cream | b-1 | Chanel | 83000.00 | 25 |
| s-10 | Toner | b-10 | Healthy Shop | 10000.00 | 10 |
| s-2 | Night Cream | b-2 | Wet n Wild | 20000.00 | 45 |
| s-3 | Cleanser | b-3 | Essence | 10000.00 | 40 |
| s-4 | Moisturizer | b-4 | Loreal Paris | 15000.00 | 20 |
| s-5 | Toner | b-5 | Sephore | 10000.00 | 30 |
| s-6 | Primer | b-6 | Maybelline | 27000.00 | 30 |
| s-7 | Essence | b-7 | Dior | 95000.00 | 10 |
| s-8 | Serum | b-8 | Dabo | 15000.00 | 20 |
| s-9 | Essence | b-9 | Mac | 15000.00 | 30 |
+-------+-------------+----------+--------------+----------+------+
10 rows in set (0.00 sec)

mysql> select * from employee;


+------+--------+------------+------------+----------+
| e_id | eName | username | phNo | password |
+------+--------+------------+------------+----------+
| e-1 | Mg Mg | Maung | 9234567891 | Mg234 |
| e-2 | Su Su | Anna | 9684868733 | Su567 |
| e-3 | Yamone | HsuYamone | 9376969424 | Hsu890 |
| e-4 | Thiri | KhinThiri | 9633639209 | Thiri465 |
| e-5 | Thuzar | ThuzarAung | 9345256340 | Zar091 |
+------+--------+------------+------------+----------+
5 rows in set (0.00 sec)

mysql> select * from owner;


+------+------------+------------+----------+
| o_id | oName | o_username | password |
+------+------------+------------+----------+
| o-1 | Hein Naing | HeinHein | Hein8567 |
| o-2 | Aye Aye | AyeThuzar | Aye4765 |
+------+------------+------------+----------+
2 rows in set (0.00 sec)

mysql> select * from sale;


+-------+------+-------+--------+------+--------+---------------------+------+
| s_id | c_id | sk_id | scount | m_id | mcount | date | e_id |
+-------+------+-------+--------+------+--------+---------------------+------+
| sa-1 | c-1 | s-4 | 10 | m-6 | 6 | 0000-00-00 00:00:00 | e-1 |
| sa-10 | c-10 | s-8 | 10 | m-8 | 9 | 0000-00-00 00:00:00 | e-2 |
| sa-2 | c-2 | s-1 | 9 | m-4 | 6 | 0000-00-00 00:00:00 | e-2 |
| sa-3 | c-3 | s-9 | 13 | m-7 | 9 | 0000-00-00 00:00:00 | e-2 |
| sa-4 | c-4 | s-5 | 19 | m-5 | 5 | 0000-00-00 00:00:00 | e-5 |
| sa-5 | c-5 | s-7 | 3 | m-6 | 5 | 0000-00-00 00:00:00 | e-4 |
| sa-6 | c-6 | s-1 | 13 | m-3 | 20 | 0000-00-00 00:00:00 | e-1 |
| sa-7 | c-7 | s-7 | 6 | m-9 | 4 | 0000-00-00 00:00:00 | e-4 |
| sa-8 | c-8 | s-10 | 3 | m-1 | 4 | 0000-00-00 00:00:00 | e-3 |
| sa-9 | c-9 | s-2 | 9 | m-2 | 6 | 0000-00-00 00:00:00 | e-3 |
+-------+------+-------+--------+------+--------+---------------------+------+
10 rows in set (0.00 sec)

mysql> desc customer;


+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| c_id | varchar(7) | NO | PRI | | |
| cName | varchar(20) | YES | | NULL | |
| email | varchar(20) | YES | | NULL | |
| phNo | varchar(15) | YES | | NULL | |
| address | varchar(20) | YES | | NULL | |
| password | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.23 sec)

mysql> desc makeup;


+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| m_id | varchar(7) | NO | PRI | | |
| item | varchar(20) | YES | | NULL | |
| brand_id | varchar(6) | NO | PRI | | |
| brand | varchar(15) | YES | | NULL | |
| price | decimal(8,2) | YES | | NULL | |
| qty | varchar(4) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
6 rows in set (0.03 sec)

mysql> desc skincare;


+----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| sk_id | varchar(7) | NO | PRI | | |
| item | varchar(20) | YES | | NULL | |
| brand_id | varchar(6) | NO | PRI | | |
| brand | varchar(15) | YES | | NULL | |
| price | decimal(8,2) | YES | | NULL | |
| qty | varchar(4) | YES | | NULL | |
+----------+--------------+------+-----+---------+-------+
6 rows in set (0.03 sec)

mysql> desc employee;


+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| e_id | varchar(7) | NO | PRI | | |
| eName | varchar(20) | YES | | NULL | |
| username | varchar(20) | YES | | NULL | |
| phNo | varchar(15) | YES | | NULL | |
| password | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
5 rows in set (0.03 sec)

mysql> desc owner;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| o_id | varchar(7) | NO | PRI | | |
| oName | varchar(20) | YES | | NULL | |
| o_username | varchar(20) | YES | | NULL | |
| password | varchar(20) | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
4 rows in set (0.05 sec)

mysql> desc sale;


+--------+------------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------+------+-----+-------------------+-------+
| s_id | varchar(7) | NO | PRI | | |
| c_id | varchar(7) | YES | MUL | NULL | |
| sk_id | varchar(6) | YES | MUL | NULL | |
| scount | varchar(4) | YES | | NULL | |
| m_id | varchar(6) | YES | MUL | NULL | |
| mcount | varchar(4) | YES | | NULL | |
| date | timestamp | NO | | CURRENT_TIMESTAMP | |
| e_id | varchar(7) | YES | MUL | NULL | |
+--------+------------+------+-----+-------------------+-------+
8 rows in set (0.03 sec)

mysql> update customer


-> set customer.cName='Phuu Myat Zin'
-> where customer.c_id='c-10';
Query OK, 1 row affected (0.39 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from customer;


+------+---------------+---------------------+-------------+--------------
+------------+
| c_id | cName | email | phNo | address |
password |
+------+---------------+---------------------+-------------+--------------
+------------+
| c-1 | Khant Khant | [email protected] | 9356873968 | Pyay |
Khant890 |
| c-10 | Phuu Myat Zin | [email protected] | 99937563335 | Magway |
Phuuzin456 |
| c-2 | Khin Khin | [email protected] | 9245259788 | Yangon | Khin490
|
| c-3 | Hsu Hsu | [email protected] | 9877359278 | Pyin Oo Lwin | Hsu560
|
| c-4 | Han Ni | [email protected] | 9457628996 | Pyay |
Hanni093 |
| c-5 | Poe Poe | [email protected] | 9896567323 | Sinde |
Poeei564 |
| c-6 | Kyaw Naing | [email protected] | 96578295789 | Mandalay | Kyaw375
|
| c-7 | Rose | [email protected] | 9936672896 | Nay Pyi Taw | Rose456
|
| c-8 | Yadanar | [email protected] | 98789723589 | Pyay |
Yadanar345 |
| c-9 | Marlar | [email protected] | 9658927994 | Yangon |
Marlar09 |
+------+---------------+---------------------+-------------+--------------
+------------+
10 rows in set (0.00 sec)

mysql> delete *
-> from skincare
-> where skincare.brand='Sephore' and skincare.brand_id='b-5';
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 '*
from skincare
where skincare.brand='Sephore' and skincare.brand_id='b-5'' at line 1
mysql> delete
-> from skincare
-> where skincare.brand='Sephore' and skincare.brand_id='b-5';
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint
fails (`cosmetics`.`sale`, CONSTRAINT `sale_ibfk_2` FOREIGN KEY (`sk_id`)
REFERENCES `skincare` (`sk_id`))
mysql> delete from skincare where sk_id not in(select sk_id from sale);
Query OK, 2 rows affected (0.13 sec)

mysql> select * from skincare;


+-------+-------------+----------+--------------+----------+------+
| sk_id | item | brand_id | brand | price | qty |
+-------+-------------+----------+--------------+----------+------+
| s-1 | Day Cream | b-1 | Chanel | 83000.00 | 25 |
| s-10 | Toner | b-10 | Healthy Shop | 10000.00 | 10 |
| s-2 | Night Cream | b-2 | Wet n Wild | 20000.00 | 45 |
| s-4 | Moisturizer | b-4 | Loreal Paris | 15000.00 | 20 |
| s-5 | Toner | b-5 | Sephore | 10000.00 | 30 |
| s-7 | Essence | b-7 | Dior | 95000.00 | 10 |
| s-8 | Serum | b-8 | Dabo | 15000.00 | 20 |
| s-9 | Essence | b-9 | Mac | 15000.00 | 30 |
+-------+-------------+----------+--------------+----------+------+
8 rows in set (0.00 sec)

mysql> update makeup set price=price*1.1 where brand_id='b-4';


Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from makeup;


+------+------------+----------+--------------+----------+------+
| m_id | item | brand_id | brand | price | qty |
+------+------------+----------+--------------+----------+------+
| m-1 | Foundation | b-1 | Chanel | 40000.00 | 10 |
| m-10 | Eyeliner | b-10 | Healthy Shop | 40000.00 | 40 |
| m-2 | lipstick | b-2 | Wet n Wild | 40000.00 | 20 |
| m-3 | Concealer | b-3 | Essence | 34000.00 | 40 |
| m-4 | Eyebrows | b-4 | Loreal Paris | 15400.00 | 40 |
| m-5 | Pallete | b-5 | Sephora | 50000.00 | 14 |
| m-6 | Bronzer | b-6 | Maybelline | 20000.00 | 24 |
| m-7 | Foundation | b-7 | Dior | 80000.00 | 23 |
| m-8 | Emultion | b-8 | Dabo | 60000.00 | 10 |
| m-9 | Lipstick | b-9 | Mac | 74000.00 | 10 |
+------+------------+----------+--------------+----------+------+
10 rows in set (0.00 sec)

mysql>mysql> select item from makeup natural join sale where sale.m_id='m-9';
+----------+
| item |
+----------+
| Lipstick |
+----------+
1 row in set (0.00 sec)

You might also like