Friday 23 April 2010

Updating an MySQL table row entry with condition WHERE

To update a single entry of an MySQL table use:


UPDATE tablename SET columnname = 'NewValue' WHERE condition;

For example on this table called "DriverTable"

|  Car     |  Driver    |
|--------|-----------|
| Fiesta   |  Kev       |
| Escort  |  Tim        |
| Vectra  |  Stu        |

To update the driver of the Escort to Fred we'd use:

UPDATE DriverTable SET Driver = 'Fred' WHERE Car = 'Escort';

No comments:

Post a Comment