MySQL retrieve value of specific newly inserted column

Cr4xy :

I have a SQL that inserts some data into a table and uses some built-in functionality, like MD5.

For example:

INSERT INTO some_rainbow_table (a, b) VALUES ("Hello", MD5("Hello"))

I would like to retrieve the inserted value of MD5("Hello") (the md5 hash of "Hello").

Can I realize this in the insert SQL itself, or do I need to query the data again with the LAST_INSERT_ID?

Akina :
INSERT INTO some_rainbow_table (a, b) 
       VALUES ("Hello", @md5 := MD5("Hello"));
SELECT @md5;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=337040&siteId=1