بناء جملة SQL في nodejs خطأ

0

لقد كتبت استعلام SQL في nodejs مثل هذا

router.get('/bookingAppointment', function (req, res, next) {
var specialty = req.query.specialty;
var doctor = req.query.doctor;
var date = req.query.date;
var newdate = date.split('/').reverse().join('-');
var stm = "SELECT numericalOrder, date"
    + "FROM appointment "
    + "WHERE specialty = '" + specialty + "' AND doctor = '" + doctor 
    + "' AND date ='" + newdate + "' AND status = 0 "
    + "ORDER BY numericalOrder asc "
    + "LIMIT 1";
con.query(stm, function (err, results) {
    if (err) throw err;
    res.send(JSON.stringify({ "status": 200, "error": null, "response": results }));
});

}) ؛

ولكن أحصل على خطأ بناء جملة SQL التالي

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 'WHERE specialty = 'KNTK' AND doctor = 'Nguyễn Văn A' AND date ='2018-7-15' AN' at line 1

أي شخص يعرف لماذا ينقطع استفساري؟

1 إجابة

2
افضل جواب

تحقق من sql ، ستجد أنه لا يوجد مسافة بينك date و FROM

var stm = "SELECT numericalOrder, date " //need to add a space here
    + "FROM appointment "
    + "WHERE specialty = '" + specialty + "' AND doctor = '" + doctor 
    + "' AND date ='" + newdate + "' AND status = 0 "
    + "ORDER BY numericalOrder asc "
    + "LIMIT 1";
:مؤلف

أسئلة ذات صلة

فوق
قائمة طعام