Biodata Erna Selviyanti

Mengenai Saya

Foto saya
Nana Imut,,,asik,,,senang punya teman banyak, suka banget ma kucing hitam ^^

Kamis, 26 Mei 2011

Hasil belajar MySQL part 2 mat kul basis data..hihi (^_^)v

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> use erna;
Database changed
mysql> select Fname,Lname,SSn,Salary from employee;
+----------+---------+-----------+----------+
| Fname | Lname | SSn | Salary |
+----------+---------+-----------+----------+
| John | Smith | 123456789 | 30000.00 |
| Franklin | Wong | 333445555 | 40000.00 |
| Joyce | English | 453453453 | 25000.00 |
| Ramesh | Narayan | 666884444 | 38000.00 |
| James | Borg | 888665555 | 55000.00 |
| Jennifer | Wallace | 987654321 | 43000.00 |
| Ahmad | Jabbar | 987987987 | 25000.00 |
| Alicia | Zelaya | 999887777 | 25000.00 |
+----------+---------+-----------+----------+
8 rows in set (0.05 sec)

mysql> select Fname,Lname,SSn,Salary from employee where Dno=5;
+----------+---------+-----------+----------+
| Fname | Lname | SSn | Salary |
+----------+---------+-----------+----------+
| John | Smith | 123456789 | 30000.00 |
| Franklin | Wong | 333445555 | 40000.00 |
| Joyce | English | 453453453 | 25000.00 |
| Ramesh | Narayan | 666884444 | 38000.00 |
+----------+---------+-----------+----------+
4 rows in set (0.00 sec)

mysql> select Lname,salary,Dname from employee,department where sex='F' and SSn=
mgr_SSn;
+---------+----------+----------------+
| Lname | salary | Dname |
+---------+----------+----------------+
| Wallace | 43000.00 | Administration |
+---------+----------+----------------+
1 row in set (0.06 sec)

mysql> select Lname as nama,salary as gaji from employee;
+---------+----------+
| nama | gaji |
+---------+----------+
| Smith | 30000.00 |
| Wong | 40000.00 |
| English | 25000.00 |
| Narayan | 38000.00 |
| Borg | 55000.00 |
| Wallace | 43000.00 |
| Jabbar | 25000.00 |
| Zelaya | 25000.00 |
+---------+----------+
8 rows in set (0.00 sec)

mysql> select Lname from employee where address like '%Houston%';
+---------+
| Lname |
+---------+
| Smith |
| Wong |
| English |
| Borg |
| Jabbar |
+---------+
5 rows in set (0.04 sec)

mysql> select count(*) as jumlah;
+--------+
| jumlah |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)


mysql> select Fname,Super_SSn from employee where Super_SSn is null;
+-------+-----------+
| Fname | Super_SSn |
+-------+-----------+
| James | NULL |
+-------+-----------+
1 row in set (0.00 sec)


mysql> select e.Lname,s.Lname from employee e,employee s where e.Super_SSn=s.SSn
;
+---------+---------+
| Lname | Lname |
+---------+---------+
| Smith | Wong |
| Wong | Borg |
| English | Wong |
| Narayan | Wong |
| Wallace | Borg |
| Jabbar | Wallace |
| Zelaya | Wallace |
+---------+---------+
7 rows in set (0.00 sec)


mysql> select Dname,Dlocation from Department d,Dept_locations f where d.Dnumber
=f.Dnumber;
+----------------+-----------+
| Dname | Dlocation |
+----------------+-----------+
| Headquarters | Houston |
| Administration | Stafford |
| Research | Bellaire |
| Research | Houston |
| Research | Sugarland |
+----------------+-----------+
5 rows in set (0.00 sec)


mysql> select Lname,Dname from employee,department d,dept_locations t where Dloc
ation='Houston' and d.Dnumber=Dno and d.Dnumber=t.Dnumber;
+---------+--------------+
| Lname | Dname |
+---------+--------------+
| Borg | Headquarters |
| Smith | Research |
| Wong | Research |
| English | Research |
| Narayan | Research |
+---------+--------------+
5 rows in set (0.00 sec)

mysql> select distinct d.dependent_name,e.Lname,Pname from employee e,dependent
d,works_on w,Project p where relationship='Son' and d.ESSn=e.SSn and e.SSn=w.ESS
n and w.pno=p.pnumber and p.pname='ProductY';
+----------------+-------+----------+
| dependent_name | Lname | Pname |
+----------------+-------+----------+
| Michael | Smith | ProductY |
| Theodore | Wong | ProductY |
+----------------+-------+----------+
2 rows in set (0.14 sec)

mysql> select Pnumber,Pname,count(*) from project,works_on where pnumber=pno gro
up by pnumber,pname;
+---------+-----------------+----------+
| Pnumber | Pname | count(*) |
+---------+-----------------+----------+
| 1 | ProductX | 2 |
| 2 | ProductY | 3 |
| 3 | ProductZ | 2 |
| 10 | Computerization | 3 |
| 20 | Reorganization | 3 |
| 30 | Newbenefits | 3 |
+---------+-----------------+----------+
6 rows in set (0.00 sec)

mysql> select Pnumber,Pname,count(*) from project,works_on where pnumber=pno gro
up by pnumber,pname having count(*) > 2;
+---------+-----------------+----------+
| Pnumber | Pname | count(*) |
+---------+-----------------+----------+
| 2 | ProductY | 3 |
| 10 | Computerization | 3 |
| 20 | Reorganization | 3 |
| 30 | Newbenefits | 3 |
+---------+-----------------+----------+
4 rows in set (0.00 sec)

mysql>

0 komentar: