MySQL 查询是否使用名称的 md5 版本更新所有条目?
mysqlmysqli database更新于 2024/11/4 15:08:17
为此,您可以使用 MD5()。让我们首先创建一个表 −
mysql> create table DemoTable1887 ( Password text, HashPassword text ); Query OK, 0 rows affected (0.00 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable1887(Password) values('John@9089');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1887(Password) values('90987_Carol');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1887(Password) values('656464_David_4343');
Query OK, 1 row affected (0.00 sec)
使用 insert 命令显示表中的一些记录 −
mysql> select * from DemoTable1887;
这将产生以下输出 −
+-------------------+--------------+ | Password | HashPassword | +-------------------+--------------+ | John@9089 | NULL| | 90987_Carol | NULL| | 656464_David_4343 | NULL| +-------------------+--------------+ 3 rows in set (0.00 sec)
以下查询使用名称的 md5 版本更新所有条目:
mysql> update DemoTable1887 set HashPassword=md5(Password); Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0
让我们再次检查表记录:
mysql> select * from DemoTable1887;
这将产生以下输出 −
+-------------------+----------------------------------+ | Password | HashPassword | +-------------------+----------------------------------+ | John@9089 | 7f92a7e09ab1a0cd3f36ec164f035c9a | | 90987_Carol | 1578fa8c47f0e53a898c8ada5c0111b4 | | 656464_David_4343 | e5ec2bd2cb55b2252be7ca9eb546659e | +-------------------+----------------------------------+ 3 rows in set (0.00 sec)
相关文章
有用资源
mysql 参考教程 - 该教程包含有关 mysql 的更多信息:https://www.cainiaomax.com/mysql/

