1. Home
  2. Computing & Technology
  3. PHP / MySQL

MySQL Tutorial: Managing MySQL data

By , About.com Guide

2 of 4

SQL Update Command - Update Data

Often it is necessary to change the data you have in your database. Let's say that Peggy (from our example) came in for a visit on her 7th birthday and we want to overwrite her old data with her new data. If you are using phpMyAdmin you can do this by clicking your database on the left (in our case "people") and then choosing "Browse" on the right. Next to Peggy's name you will see a pencil icon, this means EDIT. Click on the pencil. You can now update her information as shown (see above.)

You can also do this through the query window or command line. You have to be very careful when updating records this way and double check your syntax, as it is very easy to inadvertently overwrite several records.

UPDATE people SET age = 7, date = "2006-06-02 16:21:00", height = 1.22 WHERE name = "Peggy"

What this does is update the table "people" by setting new values for age, date, and height. The important part of this command is WHERE, which insures that the information is only updated for Peggy and not for every user in the database.

Explore PHP / MySQL
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn MySQL
  5. MySQL Tutorial - SQL Update - SQL Update Command

©2009 About.com, a part of The New York Times Company.

All rights reserved.