- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we update any value in MySQL view as we can update the values in MySQL table?
As we know that with the help of UPDATE statement we can update the values in MySQL table and in the similar way we can update the values in MySQL views. The syntax of UPDATE statement would be the same except at the place of table name we have to provide the name of the view. We are taking the data as follows from a view named ‘Info’ to illustrate the above concept −
mysql> Select * from Info; +------+---------+------------+ | Id | Name | Subject | +------+---------+------------+ | 101 | YashPal | History | | 105 | Gaurav | Literature | | 125 | Raman | Computers | | NULL | Ram | Computers | +------+---------+------------+ 4 rows in set (0.00 sec)
Now, suppose if we want to change the value of Id from NULL to any other value then with the help of following query we can update the value of view −
mysql> Update info set id = 130 where Name = 'Ram'; Query OK, 1 row affected (0.88 sec) mysql> Select * from Info; +------+---------+------------+ | Id | Name | Subject | +------+---------+------------+ | 101 | YashPal | History | | 105 | Gaurav | Literature | | 125 | Raman | Computers | | 130 | Ram | Computers | +------+---------+------------+ 4 rows in set (0.00 sec)
- Related Articles
- How can we update values in a MySQL table?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- Can we perform MySQL UPDATE and change nothing in a table?
- How can we update columns values on multiple rows with a single MySQL UPDATE statement?
- Can we update MySQL with if condition?
- How can we update MySQL table after padding a string with the values of the column?
- How can we update MySQL table after removing a particular string from the values of column?
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can I update the boolean values in MySQL?
- How can we use the output of LTRIM() and RTRIM() functions to update MySQL table?
- How can you update certain values in a table in MySQL using Python?
- How can we change MySQL user password by using UPDATE statement?
- How we can update a Python tuple element value?

Advertisements