mySQL / MariaDB - Update the value of a column in a table

by
Jeremy Canfield |
Updated: October 08 2022
| mySQL / MariaDB articles
The update command can be used to change the value of a column in a table. You will first need to log into your MariaDB or mySQL server or configure passwordless authentication and then use the -e command line option and the user must have the Update_priv.
You will probably want to display the current value in the column. One option is to first use the use <database name> command and then issue the select command. In this example, the database named db001 will be used.
use db001; select * from table001 where id=123;
Or like this.
select * from db001.table001 where id=123;
Something like this should be returned.
+------+-----------+-----------+
| id | column001 | column002 |
+------+-----------+-----------+
| 123 | Hello | World |
+------+-----------+-----------+
Here is how you would update the values in column001 and column002.
update db001.table001 set column001='Goodbye',column2='Earth' where id=123;
Then show the column again to validate that the column was updated.
select * from db001.table001 where id=123;
Something like this should be returned.
+------+---------------+
| id | column001 |
+------+---------------+
| 123 | Goodbye World |
+------+---------------+
Did you find this article helpful?
If so, consider buying me a coffee over at