- 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
MySQL query to update all entries with md5 version of name?
For this, you can use MD5(). Let us first create a table −
mysql> create table DemoTable1887 ( Password text, HashPassword text ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
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)
Display some records in the table using insert command −
mysql> select * from DemoTable1887;
This will produce the following output −
+-------------------+--------------+ | Password | HashPassword | +-------------------+--------------+ | John@9089 | NULL| | 90987_Carol | NULL| | 656464_David_4343 | NULL| +-------------------+--------------+ 3 rows in set (0.00 sec)
Here is the query to update all entries with md5 version of name:
mysql> update DemoTable1887 set HashPassword=md5(Password); Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again:
mysql> select * from DemoTable1887;
This will produce the following output −
+-------------------+----------------------------------+ | Password | HashPassword | +-------------------+----------------------------------+ | John@9089 | 7f92a7e09ab1a0cd3f36ec164f035c9a | | 90987_Carol | 1578fa8c47f0e53a898c8ada5c0111b4 | | 656464_David_4343 | e5ec2bd2cb55b2252be7ca9eb546659e | +-------------------+----------------------------------+ 3 rows in set (0.00 sec)
Advertisements