How to compare two msg.payload in a same flow

Yes. What does your payload look like before the SQL node. Add a debug before SQL node and after. Show me the output expanded. Also, your trim doesn't work. Copy & paste the code from the trim function here

Also, I didn't realise this was mariaDb

Remove TOP 1 from the SQL then add LIMIT 1 at the end

E.g...

var spokenAsText = msg.payload.trim();// or where ever the speech to text is
var SQL = "SELECT * FROM USER WHERE VOICE = '" + spokenAsText + "' LIMIT 1";
msg.topic = SQL; 
return msg;

trim() function node

var spokenAsText = msg.payload.trim();// or where ever the speech to text is
var SQL = "SELECT * FROM USER WHERE VOICE = '" + spokenAsText + "' LIMIT 1";
msg.topic = SQL; 
return msg;

so this mean successful?

Yes. It found 1 matching row.

Ps, delete the JSON node at the end. Not necessary.

if i also want check the verify data...

E.g
if verify = 1 , it will show data...

that mean i want voice and verify data match...
if one of the voice or verify no match...it also no show data..

I don't understand your question but if you mean ONLY GET DATA IF VERIFY == 1 then do this...

var spokenAsText = msg.payload.trim();// or where ever the speech to text is
var SQL = "SELECT * FROM USER WHERE VOICE = '" + spokenAsText + "' AND VERIFY = 1 LIMIT 1";
msg.topic = SQL; 
return msg;

Ps, these questions are about basic SQL syntax - not node-red. You should ask database questions on the mysql or MariaDb forums.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.