Pass msq payload to SQL query where clause

Hi node-red forum,

Is it possible to pass a msg payload to SQL query node to use in the where cluase?
I mean somenthing like this:

Which is the correct syntax?

The path of the msg payload to pass is payload.topic1[0].ID

The "better" way is to use "Parameters"

Thanks Steve.
Also if I'm using a Select query (not Insert into)?

I want to make a merge between two table and extract only raw where the ID is the one passed by a previous function output.

Parameters work with all types of queries (SELECT/UPDATE/INSERT/DELETE!

I dont think i fully understand what you are asking

Can you explain with a bit more detail please?

Do you mean to use 'parameters' like in this way?

Sure, however you need to.

e.g.

↓ When the value XXX comes from msg.payload[0].ID

then...

  • SELECT * FROM T1 where id=XXX becomes
  • SELECT * FROM T1 where id=@ID
  • and add a parameter for msg.payload[0].ID named ID

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