Pemprograman

View bisa dikatakan summary dari tabel atau beberapa tabel, dengan view, kita bisa gabungkan beberapa tabel sekaligus dan view ini tersimpan di sisi server, sehingga nanti penggunaannya tinggal panggil saja, berikut contohnya, :D:\its me\xampp\mysql\bin>mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.0.41-community-nt MySQL Community Edition (GPL)

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

mysql> create database forum;
Query OK, 1 row affected (0.00 sec)

mysql> use forum;
Database changed
mysql> create table barang(kode_barang char(3) not null primary key default’0′,n
ama_barang char(30),harga_barang int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into barang values(’001′,’mobil’,50000000);
Query OK, 1 row affected (0.05 sec)

mysql> create table jual(tgl date,kode char(3),jml_jual int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into jual values(’2007-01-01′,’001′,3);
Query OK, 1 row affected (0.00 sec)

mysql> create view jualan_view as select DATE_FORMAT(b.tgl,’%d %M %Y’) as tgl,b.kode,a.nama_barang, a.harga_barang,b.jml_jual,(a.harga_barang*b.jml_jual) as total from jual b, barang a where b.kode=a.kode_barang;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from jualan_view;
==========================================
| tgl | kode | nama_barang | harga_barang | jml_jual | total |
===========================================
| 01 January 2007 | 001 | mobil | 50000000 | 3 | 150000000 |
+———————–+——+————-+————–+———-+
1 row in set (0.00 sec)

  1. koben
    Agustus 7, 2008 pukul 4:24 am

    kalo ga salah yang bener tuh PEMROGRAMAN……🙂

  2. September 15, 2008 pukul 3:00 am

    keren juga

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: