123
rated 0 times
[
125]
[
2]
/ answers: 1 / hits: 49847
/ 10 Years ago, thu, july 10, 2014, 12:00:00
How can I check if no matching found in mysql (node.js)?
mysql.query(select * from table1 where name = 'abcd', function(error, result, field) {
if(error) {
exist(error); //No error
} else if(result) {
console.log(result); //displays '[]'
exist(null, result);
} else {
exist(null, null); //It is never execute
}
});
function exist(error, result) {
if(result)
console.log(Test:+result); //Executed and displays 'Test:'
}
My database does not contains name = 'abcd'. So, how can I check if the query does not match?
More From » mysql