Mysql insert statement with functions
Can you please help me to generate mentioned below insert statement in node syntax , I want to use md5 while inserting into database
insert into user(user_id,username,password) values ( NULL,'f',md5('t')).
connection.query('INSERT INTO user SET ?', user, function(err, result) {}
I recommend to set the query string before, something like:
var query = 'INSERT INTO user SET password=MD5(?), ?';
connection.query(query, ['supersecret', user], function (err, result) {});
where 'user' can be a json object without password key, to avoid error hope this can help you!
Hi @ashishkhanna , I hope @uribes78 was able to help you :) If you are looking for a library that provides advanced SQL constructing, a good one is the https://hiddentao.com/squel/ library.
Thanks a ton for your help
Thanks & regards,
Ashish Khanna
On 22-Sep-2016 4:48 AM, "Douglas Wilson" [email protected] wrote:
Hi @ashishkhanna https://github.com/ashishkhanna , I hope @uribes78 https://github.com/uribes78 was able to help you :) If you are looking for a library that provides advanced SQL constructing, a good one is the https://hiddentao.com/squel/ library.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mysqljs/mysql/issues/1470#issuecomment-248771174, or mute the thread https://github.com/notifications/unsubscribe-auth/AEB1DFjAoZm7IfNuDKRbnkq5DzGjydEaks5qsbtGgaJpZM4JJGyl .