Node Red SQL Node Rejects Valid SQL Statement?

This is a valid SQL statement...
SELECT Host FROM Host WHERE (Index = 1)

The above returns 1 record. Column is named 'Host' and table is named 'Host', and the table has a primary key on column 'Index'. I happen to be using MariaDB for the SQL back end.

However, the following returns zero results via the node-red-contrib-mysql node...
msg.topic = "SELECT Host FROM Host WHERE (`Index` = 1)";

Color me surprised!

Could you just try:

select Host from Host where `Index`=1

Note that mysql/mariadb have reserved words - index is one of them.

I would recommend to use more distinct wordings for tables and column namings, as it might create more problems in the future.

1 Like