I'm using node's mysql
library and trying to do a query like so:
connection.query(`SELECT * FROM table WHERE name = ? AND field = ?`, ['a', value]);
The problem I'm running into is that sometimes value = 1
but sometimes value = null
.
From my testing, results only return when the query is written as WHERE value IS null
and doesn't work with WHERE value = null
.
Q: How can I use the prepared query if the value may be null?