根据电子邮件地址更新 MySQL 列?
我们首先创建一个表格 −
mysql> create table DemoTable -> ( -> EmailAddress varchar(20), -> Score int -> ); Query OK, 0 rows affected (1.05 sec)
使用 insert 命令在表格中插入一些记录 −
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)
使用 select 语句显示表格中的所有记录 −
mysql> select *from DemoTable;
将生成以下输出 −
+------------------+-------+ | EmailAddress | Score | +------------------+-------+ | [email protected] | 67 | | [email protected] | 57 | | [email protected] | 98 | +------------------+-------+ 3 rows in set (0.00 sec)
这是根据电子邮件地址更新 MySQL 列的查询 −
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
让我们再次检查一下表格记录 −
mysql> select *from DemoTable;
将生成以下输出 −
+------------------+-------+ | EmailAddress | Score | +------------------+-------+ | [email protected] | 67 | | [email protected] | 89 | | [email protected] | 98 | +------------------+-------+ 3 rows in set (0.00 sec)
广告