- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
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)
Advertisements