Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.37-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database naruto;
Query OK, 1 row affected (0.00 sec)
mysql> use naruto;
Database changed
mysql> create table Family
-> (Fam_Num char(3) primary key,
-> Fam_Name char(20),
-> Street char(20),
-> Zip_Code decimal(6),
-> City char(20),
-> State char(15),
-> ID_No char(15));
Query OK, 0 rows affected (0.20 sec)
mysql> insert into Family values
-> ('100','Adawiah','Kg Pasir Era','18000','Kuala Krai','Kelantan','A 501');
Query OK, 1 row affected (0.08 sec)
mysql> insert into Family values
-> ('101','Hadiyatullah','Kg Enggong','18000','Kuala Krai','Kelantan','B 502
');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Family values
-> ('102','Sharifuddin','Kg Enggong','18000','Kuala Krai','Kelantan','C 503'
);
Query OK, 1 row affected (0.03 sec)
mysql> insert into Family values
-> ('103','Iklima','Jln Pahlawan','52000','Damansara','Selangor','D 504');
Query OK, 1 row affected (0.05 sec)
mysql> insert into Family values
-> ('104','Malikah','Bdr Sulaiman','53300','Port Klang','Selangor','E 505');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Family values
-> ('105','Nik Hassan','Bdr Sulaiman','53300','Port Klang','Selangor','F 506
');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Family values
-> ('106','Ahmad','Jln Kenari','52300','Wangsa Maju','Kuala Lumpur','G 507')
;
Query OK, 1 row affected (0.03 sec)
mysql> select*
-> from Family;
+---------+--------------+--------------+----------+-------------+--------------
+-------+
| Fam_Num | Fam_Name | Street | Zip_Code | City | State
| ID_No |
+---------+--------------+--------------+----------+-------------+--------------
+-------+
| 100 | Adawiah | Kg Pasir Era | 18000 | Kuala Krai | Kelantan
| A 501 |
| 101 | Hadiyatullah | Kg Enggong | 18000 | Kuala Krai | Kelantan
| B 502 |
| 102 | Sharifuddin | Kg Enggong | 18000 | Kuala Krai | Kelantan
| C 503 |
| 103 | Iklima | Jln Pahlawan | 52000 | Damansara | Selangor
| D 504 |
| 104 | Malikah | Bdr Sulaiman | 53300 | Port Klang | Selangor
| E 505 |
| 105 | Nik Hassan | Bdr Sulaiman | 53300 | Port Klang | Selangor
| F 506 |
| 106 | Ahmad | Jln Kenari | 52300 | Wangsa Maju | Kuala Lumpur
| G 507 |
+---------+--------------+--------------+----------+-------------+--------------
+-------+
7 rows in set (0.02 sec)
mysql> create table Owner
-> (ID_No char(15) primary key,
-> Type char(15),
-> Model_Car char(15),
-> PymtDate Date,
-> PymtMade decimal(8,2),
-> PymtPrice decimal(8,2),
-> PymtType char(10));
Query OK, 0 rows affected (0.06 sec)
mysql> insert into Owner values
-> ('A 501','PERODUA','MYVI','1999/05/05','450.00','600.00','Cash');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Owner values
-> ('B 502','PROTON','PERDANA','1999/10/10','450.00','500.00','Cash');
Query OK, 1 row affected (0.05 sec)
mysql> insert into Owner values
-> ('C 503','PROTON','SAGA','2000/10/10','550.00','550.00','Instalment');
Query OK, 1 row affected (0.11 sec)
mysql> insert into Owner values
-> ('D 504','PERODUA','KELISA','2001/10/15','550.00','650.00','Cash');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Owner values
-> ('E 505','PERODUA','KENARI','2003/05/25','650.00','750.00','Cash');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Owner values
-> ('F 506','MITSUBSHI','LANCER','2004/05/25','450.00','500.00','Cash');
Query OK, 1 row affected (0.03 sec)
mysql> insert into Owner values
-> ('G 507','HONDA','CIVIC','2008/08/25','550.00','600.00','Cash');
Query OK, 1 row affected (0.05 sec)
mysql> select*
-> from Owner;
+-------+-----------+-----------+------------+----------+-----------+-----------
-+
| ID_No | Type | Model_Car | PymtDate | PymtMade | PymtPrice | PymtType
|
+-------+-----------+-----------+------------+----------+-----------+-----------
-+
| A 501 | PERODUA | MYVI | 1999-05-05 | 450.00 | 600.00 | Cash
|
| B 502 | PROTON | PERDANA | 1999-10-10 | 450.00 | 500.00 | Cash
|
| C 503 | PROTON | SAGA | 2000-10-10 | 550.00 | 550.00 | Instalment
|
| D 504 | PERODUA | KELISA | 2001-10-15 | 550.00 | 650.00 | Cash
|
| E 505 | PERODUA | KENARI | 2003-05-25 | 650.00 | 750.00 | Cash
|
| F 506 | MITSUBSHI | LANCER | 2004-05-25 | 450.00 | 500.00 | Cash
|
| G 507 | HONDA | CIVIC | 2008-08-25 | 550.00 | 600.00 | Cash
|
+-------+-----------+-----------+------------+----------+-----------+-----------
-+
7 rows in set (0.02 sec)
mysql> select Fam_Num,Fam_Name,Street,Type,Model_Car from Family,Owner
-> where Owner.ID_No = Family.ID_No and type='PERODUA';
+---------+----------+--------------+---------+-----------+
| Fam_Num | Fam_Name | Street | Type | Model_Car |
+---------+----------+--------------+---------+-----------+
| 100 | Adawiah | Kg Pasir Era | PERODUA | MYVI |
| 103 | Iklima | Jln Pahlawan | PERODUA | KELISA |
| 104 | Malikah | Bdr Sulaiman | PERODUA | KENARI |
+---------+----------+--------------+---------+-----------+
3 rows in set (0.03 sec)
mysql> select Fam_Name,State,PymtDate,Model_Car,PymtPrice from Family,Owner
-> where Family.ID_No = Owner.ID_No;
+--------------+--------------+------------+-----------+-----------+
| Fam_Name | State | PymtDate | Model_Car | PymtPrice |
+--------------+--------------+------------+-----------+-----------+
| Adawiah | Kelantan | 1999-05-05 | MYVI | 600.00 |
| Hadiyatullah | Kelantan | 1999-10-10 | PERDANA | 500.00 |
| Sharifuddin | Kelantan | 2000-10-10 | SAGA | 550.00 |
| Iklima | Selangor | 2001-10-15 | KELISA | 650.00 |
| Malikah | Selangor | 2003-05-25 | KENARI | 750.00 |
| Nik Hassan | Selangor | 2004-05-25 | LANCER | 500.00 |
| Ahmad | Kuala Lumpur | 2008-08-25 | CIVIC | 600.00 |
+--------------+--------------+------------+-----------+-----------+
7 rows in set (0.00 sec)
mysql> select Fam_Name,Fam_Num,City,State,Model_Car,PymtDate from Family,Owner
-> where Owner.ID_No = Family.ID_No and type='PROTON';
+--------------+---------+------------+----------+-----------+------------+
| Fam_Name | Fam_Num | City | State | Model_Car | PymtDate |
+--------------+---------+------------+----------+-----------+------------+
| Hadiyatullah | 101 | Kuala Krai | Kelantan | PERDANA | 1999-10-10 |
| Sharifuddin | 102 | Kuala Krai | Kelantan | SAGA | 2000-10-10 |
+--------------+---------+------------+----------+-----------+------------+
2 rows in set (0.00 sec)
mysql> select Fam_Num,street,City,State,Model_Car,PymtDate from Family,Owner
-> where Owner.ID_No = Family.ID_No and type='PERODUA';
+---------+--------------+------------+----------+-----------+------------+
| Fam_Num | street | City | State | Model_Car | PymtDate |
+---------+--------------+------------+----------+-----------+------------+
| 100 | Kg Pasir Era | Kuala Krai | Kelantan | MYVI | 1999-05-05 |
| 103 | Jln Pahlawan | Damansara | Selangor | KELISA | 2001-10-15 |
| 104 | Bdr Sulaiman | Port Klang | Selangor | KENARI | 2003-05-25 |
+---------+--------------+------------+----------+-----------+------------+
3 rows in set (0.00 sec)
mysql> select Fam_Name,street,City,Model_Car,PymtDate,PymtPrice from Family,Owne
r
-> where Owner.ID_No = Family.ID_No and type='MITSUBSHI';
+------------+--------------+------------+-----------+------------+-----------+
| Fam_Name | street | City | Model_Car | PymtDate | PymtPrice |
+------------+--------------+------------+-----------+------------+-----------+
| Nik Hassan | Bdr Sulaiman | Port Klang | LANCER | 2004-05-25 | 500.00 |
+------------+--------------+------------+-----------+------------+-----------+
1 row in set (0.00 sec)
mysql> select Fam_Name,Model_Car,PymtDate from Family,Owner
-> where Owner.ID_No = Family.ID_No;
+--------------+-----------+------------+
| Fam_Name | Model_Car | PymtDate |
+--------------+-----------+------------+
| Adawiah | MYVI | 1999-05-05 |
| Hadiyatullah | PERDANA | 1999-10-10 |
| Sharifuddin | SAGA | 2000-10-10 |
| Iklima | KELISA | 2001-10-15 |
| Malikah | KENARI | 2003-05-25 |
| Nik Hassan | LANCER | 2004-05-25 |
| Ahmad | CIVIC | 2008-08-25 |
+--------------+-----------+------------+
7 rows in set (0.00 sec)
No comments:
Post a Comment