“Rivals can easily copy your improvements in quality and efficiency.
But they shouldn’t be able to copy your strategic positioning –
what distiguishes your company from all the rest.”

Michael A. Porter, 1996.

Jumat, Februari 13, 2009

Mysql : View pada Mysql 5.0.41

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 komentar:

  1. klo mau simpan path ke tabel gmn ya..?
    Contoh pada sebuah form ada textbox disitu aku ketik "E:\SOFTWARE\TOOLS" tapi yg kesimpan di tabel koq jadi "E:SOFTWARETOOLS" tanpa tanda slash...Mohon bantuannya...
    Terima kasih

    BalasHapus