Perintahnya :
DELETE FROM table_name [WHERE Clause]
Menghapus data menggunakan command prompt :
Ini akan menggunakan SQL DELETE perintah dengan klausa WHERE untuk menghapus data yang dipilih ke dalam tabel MySQL tutorials_tbl.
root@host# mysql -u root -p password; Enter password:******* mysql> use TUTORIALS; Database changed mysql> DELETE FROM tutorials_tbl WHERE tutorial_id=3; Query OK, 1 row affected (0.23 sec) mysql>
Delete data menggunakan script PHP :
<?php $dbhost = 'localhost:3036'; $dbuser = 'root'; $dbpass = 'rootpassword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'DELETE FROM tutorials_tbl WHERE tutorial_id=3'; mysql_select_db('TUTORIALS'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Gagal menghapus data: ' . mysql_error()); } echo "Delete data sukses\n"; mysql_close($conn); ?>
No comments:
Post a Comment