Skip to main content

FUNGSI STRING DALAM PEMBUATAN DATABASE

Mengambil string dari kondisi
untuk menentukan statement.
Left,Right dan Mid.
case when kdbrg='a' then 'lemari'
1.Mengambil string dari kiri(left)
sintax :
case when left(variabel,banyak karakter)
='value' then statement
else

     statement;
1302001 TahunMasuk JenjangStudi NoUrutDaftar

2.Mengambil string dari kanan(right)
sintax :
case when right(variabel,banyak karakter)
='value' then statement
else
     statement;

3.Mengambil string dari tengah(Mid)
sintax :
case when mid(variabel,start,banyak karakter)
='value' then statement
else
     statement;

Buat database dengan nama
database DBPenjualan.
Table Penjualan dengan field
seperti dibawah ini :
KdBrg varchar(12)
Isi record kedalam table
penjualan seperti dibawah ini :
KO/UD/M
LT/AL/J
TL/AB/P
KS/AX/B
insert into penjualan values
('KO/UD/M'),
('LT/AL/J'),
('TL/AB/P'),
('KS/AX/B');
tambah field NamaBrg char(30),suplier char(30)
alter table penjualan add NamaBrg char(30),
add Suplier char(30);
KodeBrg       NamaBrg   Suplier  Kota
KO/UD/M       NULL         NULL    Dim Borjong as string
LT/AL/J       NULL         NULL
TL/AB/P       NULL         NULL    Kdbrg.Text=""
KS/AX/B       NULL         NULL

update penjualan set NamaBrg=
case when left(KdBrg,2)='KO' then 'Komputer'
when left(KdBrg,2)='LT' then 'Laptop'
when left(KdBrg,2)='TL' then 'Televisi'
when left(KdBrg,2)='KS' then 'Kulkas'
else '' end;



update Penjualan set Suplier=
case when mid(KdBrg,4,2)='UD' then 'Uda Kandung'
when mid(KdBrg,4,2)='AL' then 'Alam Jaya'
when mid(KdBrg,4,2)='AB' then 'Abang Barus'
when mid(KdBrg,4,2)='AX' then 'Adu Nasib'
else '' end;
select * from Penjualan;

select KdBrg,NamaBrg,Suplier,
case when right(KdBrg,1)='M' then 'Medan'
when right(KdBrg,1)='J' then 'Jonggol'
when right(KdBrg,1)='P' then 'Pekanbaru'
when right(KdBrg,1)='B' then 'Belawan'
else '' end as Kota from Penjualan;



Comments

Popular posts from this blog

Sistem Informasi Pengiriman Kayu Menggunakan VB Net

Malam agan - agan semua.... sudah lama admin tidak posting, maklum lah lagi sibuk nyusun tugas akhir :D hari ini admin mau share gimana caraya membuat Sistem Informasi pengiriman Barang menggunakan VB Net, sebekumnya admin sudah posting membuat module koneksi di vb net 2008,  ini adalah lanjutan dari module sebelumnya, oh ia admin disini menggunakan database mysql. ok saat nya dimulai pertama rancang sebuah form seperti gambar dibawah ini : form diiatas terdiri dari : lima buah button tujuh buah textbox   satu buah listview  nama dari masing - masing komponen tersebut bisa anda sesuaikan dari koding dibawah ini : Imports MySql.Data.MySqlClient Public Class DataKayu     Sub Bersih()         BersihForm(Me)         Kunci(Me)         Simpan.ImageKey = "Simpan.Ico"         RubahTombol(0...

Disclaimer

Disclaimer for Daniel Fernando If you require any more information or have any questions about our site's disclaimer, please feel free to contact us by email at Danielbadung73@gmail.com Disclaimers for Daniel Fernando All the information on this website - www.nandoe73.blogspot.com - is published in good faith and for general information purpose only. Daniel Fernando does not make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this website (Daniel Fernando), is strictly at your own risk. Daniel Fernando will not be liable for any losses and/or damages in connection with the use of our website. Our Disclaimer was generated with the help of the Disclaimer Generator and the Privacy Policy Generator . From our website, you can visit other websites by following hyperlinks to such external sites. While we strive to provide only quality links to useful and ethical websites, we have no contro...

Privacy Policy

Privacy Policy for Daniel Fernando At Daniel Fernando, accessible from http://nandoe73.blogspot.com, one of our main priorities is the privacy of our visitors. This Privacy Policy document contains types of information that is collected and recorded by Daniel Fernando and how we use it. If you have additional questions or require more information about our Privacy Policy, do not hesitate to contact us. Log Files Daniel Fernando follows a standard procedure of using log files. These files log visitors when they visit websites. All hosting companies do this and a part of hosting services' analytics. The information collected by log files include internet protocol (IP) addresses, browser type, Internet Service Provider (ISP), date and time stamp, referring/exit pages, and possibly the number of clicks. These are not linked to any information that is personally identifiable. The purpose of the information is for analyzing trends, administering the site, tracking users' move...