Joh*_*own 1 mysql string hash insert
我想创建一个脚本来填充数据库进行测试.如何设置要散列的字符串并将其插入数据库?
我有:
INSERT INTO `loop`.`User`
(`userID`,
`firstName`,
`lastName`,
`email`,
`password`,
`userName`,
`bio`,
`spamCount`)
VALUES
('gZvTtlPtjGRqeMBaLji3HxoKB5EZCsNL',
'Joe',
'Smith',
'test0@email.com',
SHA2('testgZvTtlPtjGRqeMBaLji3HxoKB5EZCsNL', 256),
'test0@email.com',
"TEST BIO",
0);
Run Code Online (Sandbox Code Playgroud)
如何在同一语句中散列字符串和INSERT?
wog*_*and 11
您可以插入一个SELECT而不是VALUES在其中一个输入上运行函数:
INSERT INTO `loop`.`User`
(`userID`,
`firstName`,
`lastName`,
`email`,
`password`,
`userName`,
`bio`,
`spamCount`)
SELECT
'gZvTtlPtjGRqeMBaLji3HxoKB5EZCsNL',
'Joe',
'Smith',
'test0@email.com',
SHA2('testgZvTtlPtjGRqeMBaLji3HxoKB5EZCsNL', 256),
'test0@email.com',
"TEST BIO",
0;
Run Code Online (Sandbox Code Playgroud)