I want to insert current values, which is BlockData, BlockHash, and dataid from client side, and only BlockLastHash I want to select its value from the last row in the same table. However, BlockLastHash saves the command itself not the value.
The code:
connection.query("INSERT INTO `pow` (`BlockData`, `BlockHash`, `BlockLastHash`, `dataid`) VALUES ('"+blockdata+"', '"+hash+"', '( SELECT `BlockHash` FROM `pow` ORDER BY id DESC LIMIT 1 )' , '"+id+"') ", (err, res) => {
if(err) throw err;
console.log("1 Block inserted");
});
The output in BlockLastHash is the same command which is
( SELECT `BlockHash` FROM `pow` ORDER BY id DESC LIMIT 1 )
How to solve this please? Thanks in advance