Node is giving me this error message
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TIMESTAMPDIFF(second, entered_at, current_timestamp) < 1' at line 1
for this mysql query
var myQuery = "SELECT * FROM checkins WHERE user_id = " + req.body.userID + "AND TIMESTAMPDIFF(SECOND, entered_at, current_timestamp) < 1;";
I've already tested whether the query works or not by running it on mysql on the terminal directly with no errors. I'm not entirely sure why node is giving me this error. Thanks in advance!
(entered_at is a timestamp column in my checkins table)
Ah, stupid mistake. Do watch your spacing.
The + "A
changed to + " A
. Definitely won't be making that mistake again.
var myQuery = "SELECT * FROM checkins WHERE user_id = " + req.body.userID + "AND TIMESTAMPDIFF(SECOND, entered_at, current_timestamp) < 1;";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.