Having entered your data into a database table, you might like to change it. Whether you want to correct a spelling mistake, or change the date attached to a joke, such alterations are made using the UPDATE command. This command contains elements of the INSERT command (that set column values) and of the SELECT command (that pick out entries to modify). The general form of the UPDATE command is as follows:
mysql>UPDATE table_name SET -> col_name = new_value, ... ->WHERE conditions;
So, for example, if we wanted to change the date on the joke we entered above, we'd use the following command:
mysql>UPDATE Jokes SET JokeDate="1990-04-01" WHERE ID=1;
Here's where that ID column comes in handy. It allows us to easily single out a joke for changes. The WHERE clause here works just like it does in the SELECT command. This next command, for example, changes the date of all entries that contain the word "chicken":
mysql>UPDATE Jokes SET JokeDate="1990-04-01" ->WHERE JokeText LIKE "%chicken%";