
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to replace a column value
Let us first create a table −
mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, Score int ); Query OK, 0 rows affected (0.45 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(Score) values(56); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable(Score) values(78); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable(Score) values(34); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Score) values(55); Query OK, 1 row affected (0.37 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------+ | StudentId | Score | +-----------+-------+ | 1 | 56 | | 2 | 78 | | 3 | 34 | | 4 | 55 | +-----------+-------+ 4 rows in set (0.00 sec)
Following is the query to replace column value −
mysql> update DemoTable set Score=95 where StudentId=3; Query OK, 1 row affected (0.12 sec) Rows matched : 1 Changed : 1 Warnings : 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------+ | StudentId | Score | +-----------+-------+ | 1 | 56 | | 2 | 78 | | 3 | 95 | | 4 | 55 | +-----------+-------+ 4 rows in set (0.00 sec)
- Related Articles
- MySQL query to replace special characters from column value
- Replace only a specific value from a column in MySQL
- Add user defined value to a column in a MySQL query?
- MySQL query to replace backslash from a varchar column with preceding backslash string values
- MySQL query to replace a string after the last / in a column with directory links?
- MySQL query to remove a value with only numbers in a column
- MongoDB query to replace value with aggregation?
- MySQL query to select column where value = one or value = two, value = three, etc?
- MySQL SELECT to add a new column to a query and give it a value?
- MySQL query to find sum of fields with same column value?
- MySQL query to delete last two words from every column value
- How to use MySQL LIKE query to search a column value with % in it?
- MongoDB query to replace value in an array?
- How to replace a particular character in a MySQL column?
- MySQL query to select the nth highest value in a column by skipping values

Advertisements