just based on my experience during the web programming..
saat bikin aplikasi PHP dan MySQL tentunya banyak perintah2 sql yang dijalankan dengan php.. tinggal memperhatikan cara penulisannya aja..
Manipulasi data di MySQL ada 3 yaitu:
1. Insert
Buat masukin data.
Syntaxnya : insert into table_name (field_name) Values ('isi_tabel');
contoh sederhananya : insert into buku (judul,pengarang,tahun_terbit) values ('Avatar','Boim',2010);
2. Update
Buat ngedit data yang uda ada.
Syntaxnya : Update table_name set field_yg_mo diupdate = 'data_baru' where id=...
Contoh lage : Update buku set judul='Avatar Eeng' where id=12;
3. Delete
apalage kalo bukan buat ngehapus data.
Syntaxnya :
Delete from table_name (kalo yang ini buat menghapus semua data)
Delete from table_name where id=.. (buat menghapus data dengan kriteria tertentu)
Contohnya: Delete from buku where id=100;
Semua syntax SQl selalu diakhiri ; (titik koma)
Manipulasi data dengan SQL atau SQL Query pada dasarnya adalah menggunakan perintah select..
Misalnya:
# Select * from table_name : menampilkan semua data dari sebuah tabel
ex: select * from buku;
# select * from table_name order by field_name : menampilkan semua data dari tabel urut berdasar field tertentu asc
ex: select * from buku order by judul;
# select * from table_name order by field_name desc : menampilkan semua data dari tabel urut berdasar field tertentu desc
ex: select * from buku order by judul desc;
# select * from table_name where field_name=x : menampilkan data dari tabel dengan kriteria field_name tertentu
ex: select * from buku where pengarang='Nobita';
# select * from table_name where field_name like '%karakter%'; : menampilkan data dari tabel dengan kriteria tertentu, bisanya digunakan untuk pencarian.
ex: select * from buku where judul like '%kata_kunci%';
*kata kunci disini bisa diganti sembarang..
yang sering dipake sih kayaknya itu, bersambung aja di artikel yang laennya,, :)
thiz blog, I have made to share everything that I know, everything that I like and also I have learned especially about information technology, my diploma study. But sometimes all the knowledge comes from the experience, didn't? and yeah, I would like to share another things to, about what I like.. So.. keep watchin9!
Thursday, July 29, 2010
Tuesday, July 20, 2010
Quotation of the day :)
Here is my favorite Quotation about life...
Life is an opportunity, benefit from it.
Life is beauty, admire it.
Life is bliss, taste it.
Life is a dream, realize it.
Life is a challenge, meet it.
Life is a duty, complete it.
Life is a game, play it.
Life is costly, care for it.
Life is wealth, keep it.
Life is love, enjoy it.
Life is mystery, know it.
Life is a promise, fulfill it.
Life is sorrow, overcome it.
Life is a song, sing it.
Life is a struggle, accept it.
Life is tragedy, confront it.
Life is an adventure, dare it.
Life is luck, make it.
Life is too precious, do not destroy it.
Life is life, fight for it..
Subscribe to:
Posts (Atom)