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('[email protected]',67); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('[email protected]',57); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('[email protected]',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 | +------------------+-------+ | [email protected] | 67 | | [email protected] | 57 | | [email protected] | 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='[email protected]'; 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 | +------------------+-------+ | [email protected] | 67 | | [email protected] | 89 | | [email protected] | 98 | +------------------+-------+ 3 rows in set (0.00 sec)