Menghapus Record


Pernyataan DELETE FROM  digunakan menghapus records dari tabel database.

pernulisan

DELETE FROM nama_table
WHERE column_name = nilai

Contoh

tabel “Person”.

FirstName LastName Age
Peter Griffin 35
Glenn Quagmire 33

Contoh berikut menghapus records dalam tabel “Person” dimana LastName=’Griffin’:

<?php $con = mysql_connect("localhost","peter","abc123");
if (!$con)   {   die('Could not connect: ' . mysql_error());   }
mysql_select_db("my_db", $con);
mysql_query("DELETE FROM Person WHERE LastName='Griffin'");
mysql_close($con); ?>

Setelah dijalankan, akan terlihat seperti ini

FirstName LastName Age
Glenn Quagmire 33
Iklan

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: