[SOLVED] Why is node js returning all tinyint data even though I select * where it is 0?


I tried the same sql command in phpmyadmin and it works fine but different in node js so I don’t think it’s a problem with the sql command.

  app.get('/tag/:id', (req, res) => {
    const id = req.params.id;
      connection.query("SELECT * from news   WHERE ? = 0",id, function (error, results, fields) {
        if (error) {
      else {

When I use the

SELECT * from news WHERE ? = 0 

It will return all values.

But when I use

   SELECT * from news WHERE ? = 1

It doesn’t return any values ​​at all.

This is my database structure.
enter image description here
enter image description here


Are you trying to select to use which boolean field to select on? This can’t be done using query parameters.

Answered By – Vesa Karjalainen

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *