Pages

Subscribe:

Monday, 28 May 2012

05 Cara Insert, Update, Delete Database SQL dengan Query

disini yang ingin memberi info dan memperjelas mengenai Insert, Update, Delete data dalam Database menggunakan QueryAnalyzer. ini dia perintahnya :

INSERT :

INSERT INTO nama tabel VALUES ('nilai string',nilai angka)

contoh :

INSERT INTO BARANG VALUES('A001','Television',5,1300000)

pastikan bahwa urutan values sesuai dengan urutan field pada database, Jika tidak ingin berurutan anda bisa menambahkan nama field sebelum values jadi.



INSERT INTO nama tabel (Field1string,Feld2int)VALUES ('nilai string',nilai angka)

contoh :

INSERT INTO BARANG (namabrg,qty,harga,kodebrg) VALUES('Television',5,1300000,'A001')

dengan menambahkan nama field anda juga bisa mengisi data dengan nilai Null, misalkan anda memiliki 4 field dalam tabel kodebrg,namabrg,qty,harga dan anda ingin memberi nilai Null pada harga cukup tambakan 3 nama field dan isi dengan 3 nilai maka anda akan mendapatkan 1 field bernilai Null.

UPDATE :

UPDATE nama tabel SET nama field = isi field WHERE primarykey field = kriteria

contoh :

UPDATE barang SET namabrg='DVD Player' where kodebrg='A001'

barang adalah nama tabel, namabrg adalah nama field yang nilainya ingin diUpdate = isifield adalah nilai Update yang diganti, primarykey field adalah nama primarykey pada tabel digunakan sebagai penentu , kriteria adalah nilai dimana yang akan diUpdate, Contoh diatas saya ingin mengUpdate Namabrg dengan isi DVD Player dimana  kodebrg yang memiliki nilai 'A001'. untuk update nilai dalam beberapa field bisa ditambahakan setlah namabrg='DVD Player. Contoh saya ingin update namabrg,qty,dan harga dengan kriteria kodebrg='A001'.

UPDATE barang SET namabrg='Playstation 2',qty=20,harga=1700000 where kodebrg='A001'

DELETE :

DELETE nama tabel WHERE primarykey field = kriteria

contoh :

Delete barang where kodebrg='A003'

barang adalah nama tabel kodebrg adalan nama primary key field dan A003 adalah nilai kriteria, jadi diatas saya menghapus sebaris Nilai yang memiliki nilai kodebrg = A003 dalam tabel barang. Selesai.


semoga info ini bisa bermanfaat untuk anda :)

9 comments:

  1. banyak cara ya buat simpan data :D

    ReplyDelete
  2. Having read this I thought it was really informative. I appreciate you spending some
    time and energy to put this informative article together. I once again find myself personally spending way too much time both reading and
    posting comments. But so what, it was still worthwhile!
    Also visit my blog post ... van Nelle halfzware

    ReplyDelete
  3. Why visitors still use to read news papers when in this technological world all is available on
    net?
    My site :: borkum riff

    ReplyDelete
  4. I must thank you for the efforts you've put in writing this website. I am hoping to see the same high-grade content from you in the future as well. In truth, your creative writing abilities has encouraged me to get my very own blog now ;)
    Also see my page :: samson tobacco

    ReplyDelete
  5. Good post. I learn something totally new and challenging on websites I stumbleupon everyday.
    It will always be helpful to read articles from other authors and use something from other
    web sites.
    My homepage ; mac baren cube

    ReplyDelete
  6. Great weblog right here! Additionally your site lots up very fast!

    What web host are you using? Can I am getting your associate link to your host?
    I want my web site loaded up as fast as yours lol
    My homepage ... amber leaf

    ReplyDelete
  7. When I originally commented I clicked the "Notify me when new comments are added"
    checkbox and now each time a comment is added I get four emails with the same
    comment. Is there any way you can remove people from that
    service? Thank you!
    My web blog ... immobilien alanya türkei

    ReplyDelete
  8. Wow, that's what I was seeking for, what a stuff! existing here at this website, thanks admin of this web page.
    Feel free to surf my site ... skin lightening

    ReplyDelete
  9. Way cool! Some extremely valid points! I appreciate you writing this write-up plus the rest of the website is really good.
    Here is my webpage http://insainia.com/

    ReplyDelete

 
back to top