

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Updating only a single column value in MySQL?
Let us first create a table −
mysql> create table DemoTable770 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.65 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable770(Value) values(10); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable770(Value) values(90); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable770(Value) values(160); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable770(Value) values(450); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable770(Value) values(560); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable770;
This will produce the following output -
+----+-------+ | Id | Value | +----+-------+ | 1 | 10 | | 2 | 90 | | 3 | 160 | | 4 | 450 | | 5 | 560 | +----+-------+ 5 rows in set (0.00 sec)
Following is the query to update only a single column value −
mysql> update DemoTable770 set Value=Value+150 where Id=4; Query OK, 1 row affected (0.52 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the description of the view −
mysql> select *from DemoTable770;
This will produce the following output -
+----+-------+ | Id | Value | +----+-------+ | 1 | 10 | | 2 | 90 | | 3 | 160 | | 4 | 600 | | 5 | 560 | +----+-------+ 5 rows in set (0.00 sec)
- Related Questions & Answers
- Update only a single column value in MySQL
- A single MySQL query to update only specific records in a range without updating the entire column
- Updating boolean value in MySQL?
- Get only a single value from a specific MySQL row?
- Subtracting a number from a single MySQL column value?
- Replace only a specific value from a column in MySQL
- Decrement only a single value in MongoDB?
- MySQL select only a single value from 5 similar values?
- Insertion in a MySQL table with only a single column set as auto_increment?
- Updating a MySQL table row column by appending a value from user defined variable?
- Increment only a single value in MongoDB document?
- How to insert only a single column into a MySQL table with Java?
- MySQL query to remove a value with only numbers in a column
- Updating default value of new column in SAP system
- Updating a MySQL column that contains dot (.) in its name?
Advertisements