Perintahnya :
UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]
Ini akan menggunakan perintah SQL UPDATE dengan klausa WHERE untuk memperbarui data yang dipilih ke dalam tabel MySQL tutorials_tbl.
Enter password:******* mysql> use TUTORIALS; Database changed mysql> UPDATE tutorials_tbl -> SET tutorial_title='Belajar JAVA' -> WHERE tutorial_id=3; Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql>
Update menggunakan PHP Script :
root@host# mysql -u root -p password;<?php $dbhost = 'localhost:3036'; $dbuser = 'root'; $dbpass = 'rootpassword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'UPDATE tutorials_tbl SET tutorial_title="Belajar JAVA" WHERE tutorial_id=3'; mysql_select_db('TUTORIALS'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data succes\n"; mysql_close($conn); ?>
No comments:
Post a Comment