Loading video...
SQL Command: UPDATE
- An
UPDATEstatement is an SQL command used to update the data values of specified rows in database tables. It has the syntax:UPDATE items SET name=‘Blue T-Shirt’, price=8.99 WHERE itemID=1001;
- Its
WHEREclause operates just like forSELECTstatements to be able to select specific rows from a table. It can thus also use comparison & logical operations in its where condition. - To update column values for all rows in a table, the
WHEREclause is simply omitted:UPDATE items SET imageFileExt=‘jpg’;
- Running an
UPDATEquery from PHP works the same way as running anINSERTquery from PHP because it does not return a result set. To process anUPDATEquery's results:- The result of the
query()method can be tested for its truth value to test the success of theUPDATE. - The
MySQLi->affected_rowsproperty can also be accessed to get the number of rows that were updated.
- The result of the
-
htmlspecialchars()is a built-in PHP function that will encode any HTML special characters within a string as proper HTML entities. The function will encode the following special characters by default:“– becomes"<- becomes<>- becomes>&– becomes&
-
addslashes()is a built-in PHP function that is used to escape characters that should be escaped in database queries. It will escape the following characters:‘– escaped as\’“– escaped as\”
- Additional Resources:
SQL Command: UPDATE
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.



































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview