Rumus PHP

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\RIZAL>cd c:\apache\mysql\bin

C:\apache\mysql\bin>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.32-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| DCC1               |
| erwanto            |
| erwanto dcc        |
|                    |
+--------------------+
14 rows in set (0.00 sec)


mysql> use erwanto;
Database changed
mysql> show tables;
+----------------+
| Tables_in_edho |
+----------------+
| dosen          |
| gaji           |
| kelas          |
| mahasiswa      |
| matakuliah     |
| progstudy      |
+----------------+
6 rows in set (0.00 sec)


mysql> desc dosen;
+--------------+-------------+------+-----+---------+----------------+
| Field        | Type        | Null | Key | Default | Extra          |
+--------------+-------------+------+-----+---------+----------------+
| dosen_no     | int(10)     |      | PRI | NULL    | auto_increment |
| dosen_nama   | varchar(25) | YES  |     | NULL    |                |
| dosen_alamat | varchar(35) | YES  |     | NULL    |                |
| dosen_telp   | varchar(20) | YES  |     | NULL    |                |
+--------------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)


mysql> select * from dosen;
+----------+----------------+--------------+--------------+
| dosen_no | dosen_nama     | dosen_alamat | dosen_telp   |
+----------+----------------+--------------+--------------+
|        1 | Budiyanto      | Rajabasa     | 08154049854  |
|        2 | Eris Ristemena | Panjang      | 081369034830 |
|        3 | Marco          | Rajabasa     |              |
|        4 | Pitrawati      | Kedaton      | (0721)787878 |
+----------+----------------+--------------+--------------+
4 rows in set (0.00 sec)


mysql> select * from mahasiswa;
+--------+-----------------+----------------+----------------+--------------+---
-----------+----------------+---------+-------------+-------------+------------+

| mhs_no | mhs_nama        | mhs_alamat     | mhs_telp       | mhs_tplahir  | mh
s_tgllahir | mhs_jnskelamin | ps_kode | mhs_thmasuk | mhs_jenjang | kelas_desc |

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

|      1 | Arief Budiman   | Teluk Betung   | (0721) 8827383 | Teluk Betung | 19
78-02-19   | L              | MI      | 2000        | D3          | 1D3-MI1    |

|      2 | Aris Maryadi    | Kemiling       | (0721) 8856383 | Teluk Betung | 19
79-11-19   | L              | MI      | 2001        | D3          | 1D3-MI2    |

|      3 | Bambang Harie   | Panjang        |                | Panjang      | 19
76-07-19   | L              | KA      | 1999        | D3          | 1D3-KA     |

|      4 | Rosa Ferosa     | Panjang        | 0812989898     | Panjang      | 19
78-02-18   | P              | BA      | 1999        | D3          | 1D3-BA     |

|      5 | Zulia           | Tanjung Karang | (0721)877872   | Kalianda     | 19
81-01-08   | P              | BA      | 1999        | D3          | 1D3-BA     |

|      6 | Aris Santoso    | Kalianda       | (0727)877872   | Kalianda     | 19
80-03-05   | L              | MI      | 2002        | D1          | 1D1-MI     |

|      7 | Bambang Santoso | Metro          | (0722)87877    | Metro        | 19
80-04-09   | L              | KA      | 2003        | D1          | 1D3-KA     |

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

7 rows in set (0.02 sec)


mysql> select *from gaji;
+---------+----------+------------+
| gaji_no | dosen_no | gaji_pokok |
+---------+----------+------------+
|       1 |        1 |    1500000 |
|       2 |        2 |    1000000 |
|       3 |        3 |    2500000 |
|       4 |        4 |    2000000 |
+---------+----------+------------+
4 rows in set (0.00 sec)


mysql> select * from kelas;
+------------+----------+-------+
| kelas_desc | dosen_no | mk_no |
+------------+----------+-------+
| 1D3-MI1    |        1 |     1 |
| 1D3-MI1    |        1 |     2 |
| 1D3-MI2    |        2 |     1 |
| 1D3-MI2    |        2 |     2 |
| 1D1-MI     |        1 |     1 |
| 1D1-MI     |        2 |     2 |
| 1D3-KA     |        4 |     3 |
| 1D3-KA     |        4 |     4 |
| 1D1-KA     |        4 |     3 |
| 1D1-KA     |        4 |     4 |
| 1D3-BA     |        3 |     5 |
| 1D3-BA     |        3 |     6 |
+------------+----------+-------+
12 rows in set (0.00 sec)


mysql> select * from matakuliah;
+-------+---------------+---------+
| mk_no | mk_desc       | ps_kode |
+-------+---------------+---------+
|     1 | Delphi        | MI      |
|     2 | Visual Basic  | MI      |
|     3 | Ms Word       | KA      |
|     4 | Ms Excell     | KA      |
|     5 | Grammer       | BA      |
|     6 | Comprehension | BA      |
+-------+---------------+---------+
6 rows in set (0.00 sec)


mysql> select * from progstudy;
+---------+-----------------------+
| ps_kode | ps_desc               |
+---------+-----------------------+
| MI      | Manajemen Informatika |
| KA      | Komputer Akuntansi    |
| BA      | Bahasa Asing          |
+---------+-----------------------+
3 rows in set (0.00 sec)


mysql> select * from mahasiswa;
+--------+-----------------+----------------+----------------+--------------+---
-----------+----------------+---------+-------------+-------------+------------+

| mhs_no | mhs_nama        | mhs_alamat     | mhs_telp       | mhs_tplahir  | mh
s_tgllahir | mhs_jnskelamin | ps_kode | mhs_thmasuk | mhs_jenjang | kelas_desc |

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

|      1 | Arief Budiman   | Teluk Betung   | (0721) 8827383 | Teluk Betung | 19
78-02-19   | L              | MI      | 2000        | D3          | 1D3-MI1    |

|      2 | Aris Maryadi    | Kemiling       | (0721) 8856383 | Teluk Betung | 19
79-11-19   | L              | MI      | 2001        | D3          | 1D3-MI2    |

|      3 | Bambang Harie   | Panjang        |                | Panjang      | 19
76-07-19   | L              | KA      | 1999        | D3          | 1D3-KA     |

|      4 | Rosa Ferosa     | Panjang        | 0812989898     | Panjang      | 19
78-02-18   | P              | BA      | 1999        | D3          | 1D3-BA     |

|      5 | Zulia           | Tanjung Karang | (0721)877872   | Kalianda     | 19
81-01-08   | P              | BA      | 1999        | D3          | 1D3-BA     |

|      6 | Aris Santoso    | Kalianda       | (0727)877872   | Kalianda     | 19
80-03-05   | L              | MI      | 2002        | D1          | 1D1-MI     |

|      7 | Bambang Santoso | Metro          | (0722)87877    | Metro        | 19
80-04-09   | L              | KA      | 2003        | D1          | 1D3-KA     |

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

7 rows in set (0.00 sec)


mysql> select mhs_nama,mhs_jnskelamin
    -> from mahasiswa
    -> where mhs_jnskelamin='l';
+-----------------+----------------+
| mhs_nama        | mhs_jnskelamin |
+-----------------+----------------+
| Arief Budiman   | L             |
| Aris Maryadi    | L               |
| Bambang Harie   | L            |
| Aris Santoso    | L                |
| Bambang Santoso | L           |
+-----------------+---------------+
5 rows in set (0.00 sec)


mysql> select mhs_nama,mhs_jnskelamin,mhs_alamat
    -> from mahasiswa
    -> where mhs_jnskelamin='l' and mhs_alamat='panjang';
+---------------+----------------+------------+
| mhs_nama      | mhs_jnskelamin | mhs_alamat |
+---------------+----------------+------------+
| Bambang Harie | L              | Panjang    |
+---------------+----------------+------------+
1 row in set (0.00 sec)


mysql> select mhs_nama,mhs_alamat
    -> from mahasiswa
    -> where mhs_alamat='panjang' or mhs_alamat='teluk betung';
+---------------+--------------+
| mhs_nama      | mhs_alamat   |
+---------------+--------------+
| Arief Budiman | Teluk Betung |
| Bambang Harie | Panjang      |
| Rosa Ferosa   | Panjang      |
+---------------+--------------+
3 rows in set (0.00 sec)


mysql> select mhs_nama,mhs_jnskelamin,mhs_alamat
    -> from mahasiswa
    -> where mhs_jnskelamin='l'
    -> and (mhs_alamat='panjang' or mhs_alamat='teluk betung');
+---------------+----------------+--------------+
| mhs_nama      | mhs_jnskelamin | mhs_alamat   |
+---------------+----------------+--------------+
| Arief Budiman | L              | Teluk Betung |
| Bambang Harie | L              | Panjang      |
+---------------+----------------+--------------+
2 rows in set (0.00 sec)

mysql> select mhs_nama, mhs_alamat
    -> from mahasiswa
    -> where mhs_alamat!='panjang';
+-----------------+----------------+
| mhs_nama        | mhs_alamat     |
+-----------------+----------------+
| Arief Budiman   | Teluk Betung   |
| Aris Maryadi    | Kemiling       |
| Zulia           | Tanjung Karang |
| Aris Santoso    | Kalianda       |
| Bambang Santoso | Metro          |
+-----------------+----------------+
5 rows in set (0.00 sec)

mysql> select mhs_nama
    -> from mahasiswa
    -> where mhs_nama like 'aris%';
+--------------+
| mhs_nama     |
+--------------+
| Aris Maryadi |
| Aris Santoso |
+--------------+
2 rows in set (0.00 sec)

mysql> select mhs_nama
    -> from mahasiswa
    -> where mhs_nama like 'b%';
+-----------------+
| mhs_nama        |
+-----------------+
| Bambang Harie   |
| Bambang Santoso |
+-----------------+
2 rows in set (0.00 sec)

mysql> select mhs_nama
    -> from mahasiswa
    -> where mhs_nama like 'a%';
+---------------+
| mhs_nama      |
+---------------+
| Arief Budiman |
| Aris Maryadi  |
| Aris Santoso  |
+---------------+
3 rows in set (0.00 sec)

mysql> select mhs_no,mhs_nama,mhs_jnskelamin
    -> from mahasiswa
    -> where mhs_jnskelamin='l'
    -> order by mhs_no;
+--------+-----------------+----------------+
| mhs_no | mhs_nama        | mhs_jnskelamin |
+--------+-----------------+----------------+
|      1 | Arief Budiman   | L              |
|      2 | Aris Maryadi    | L              |
|      3 | Bambang Harie   | L              |
|      6 | Aris Santoso    | L              |
|      7 | Bambang Santoso | L              |
+--------+-----------------+----------------+
5 rows in set (0.02 sec)

mysql> select mhs_no,mhs_nama,mhs_jnskelamin
    -> from mahasiswa
    -> where mhs_jnskelamin='l'
    -> order by mhs_nama;
+--------+-----------------+----------------+
| mhs_no | mhs_nama        | mhs_jnskelamin |
+--------+-----------------+----------------+
|      1 | Arief Budiman   | L              |
|      2 | Aris Maryadi    | L              |
|      6 | Aris Santoso    | L              |
|      3 | Bambang Harie   | L              |
|      7 | Bambang Santoso | L              |
+--------+-----------------+----------------+
5 rows in set (0.00 sec)

mysql> select curdate();
+------------+
| curdate()  |
+------------+
| 2010-10-13 |
+------------+
1 row in set (0.01 sec)

mysql> select year (curdate());
+------------------+
| year (curdate()) |
+------------------+
|             2010 |
+------------------+
1 row in set (0.00 sec)

mysql> select month (curdate());
+-------------------+
| month (curdate()) |
+-------------------+
|                10 |
+-------------------+
1 row in set (0.00 sec)


mysql> select dayofmonth (curdate());
ERROR 1064: You have an error in your SQL syntax near '(curdate())' at line 1
mysql> select year(curdate())-year(mhs_tgllahir) from mahasiswa;
+------------------------------------+
| year(curdate())-year(mhs_tgllahir) |
+------------------------------------+
|                                 32 |
|                                 31 |
|                                 34 |
|                                 32 |
|                                 29 |
|                                 30 |
|                                 30 |
+------------------------------------+
7 rows in set (0.00 sec)


mysql> select mhs_nama
    -> from mahasiswa
    -> where (year(curdate())-year(mhs_tgllahir))=32;
+---------------+
| mhs_nama      |
+---------------+
| Arief Budiman |
| Rosa Ferosa   |
+---------------+
2 rows in set (0.00 sec)

mysql>
close
==[ Klik disini 1X ] [ Close ]==