Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

SQL Command: UPDATE

  • An UPDATE statement 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 WHERE clause operates just like for SELECT statements 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 WHERE clause is simply omitted:
    UPDATE items SET imageFileExt=‘jpg’;
  • Running an UPDATE query from PHP works the same way as running an INSERT query from PHP because it does not return a result set. To process an UPDATE query's results:
    • The result of the query() method can be tested for its truth value to test the success of the UPDATE.
    • The MySQLi->affected_rows property can also be accessed to get the number of rows that were updated.
  • 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 &lt;
    • > - becomes &gt;
    • & – becomes &amp;
  • 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.

Advanced PHP Training with MySQL