
- 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
Update MySQL column based on email address?
Let us first create a table −
mysql> create table DemoTable -> ( -> EmailAddress varchar(20), -> Score int -> ); Query OK, 0 rows affected (1.05 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris@gmail.com',67); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('Robert@gmail.com',57); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David@gmail.com',98); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------------+-------+ | EmailAddress | Score | +------------------+-------+ | Chris@gmail.com | 67 | | Robert@gmail.com | 57 | | David@gmail.com | 98 | +------------------+-------+ 3 rows in set (0.00 sec)
Here is the query to update MySQL column based on email address −
mysql> update DemoTable -> set Score=89 -> where EmailAddress='Robert@gmail.com'; Query OK, 1 row affected (0.25 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 −
+------------------+-------+ | EmailAddress | Score | +------------------+-------+ | Chris@gmail.com | 67 | | Robert@gmail.com | 89 | | David@gmail.com | 98 | +------------------+-------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- Update a column based on another MySQL table’s column
- MySQL update a column with an int based on order?
- Update a table based on StudentId value in MySQL?
- Validate Email address in Java
- MySQL query to update different fields based on a condition?
- How to select domain name from email address in MySQL?
- How to check email Address Validation in Android on edit Text
- How to validate Email Address in Android on EditText using Kotlin?
- SUM a column based on a condition in MySQL
- Python program to validate email address
- Update quantity in MongoDB based on two conditions?
- Search and update array based on key JavaScript
- How to validate email address in JavaScript?
- Find a list of invalid email address from a table in MySQL?
- How to validate an email address in PHP ?
Advertisements