Answer the question
In order to leave comments, you need to log in
How to set optional parameters in mysql?
connection.query('SELECT * FROM `mainreservation` WHERE `status`='+ arh +' AND from_who='+ who +' AND date='+ date +';', function(err, rows, fields) {
if (err) throw err;
})
Answer the question
In order to leave comments, you need to log in
you need to manually check if there is such a parameter or not, and if it is, then add the query string.
$sql = 'select * from table where 1=1';
if($param1)
$sql .= " AND param1=param1";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question