Using query result as input for sql query

Hello all :wave:

I have a JS query that returns a string like:

"investing*{{table2.selectedRow.data.investing}}+banking*{{table2.selectedRow.data.banking}}"

where investing is a column in my SQL database filled with 1s and 0s. The selectedRow from table2 also contains either a 1 or 0. So, in my SQL query, I want to use that JS query as an input for some arithmetic in the following way:

SELECT name,
{{MyJSQueryResult}}
AS total_points
FROM MySQLDatabase;

The issue is that this SQL query uses my JS query result as a string, and doesn't get the values for {{table2.selectedRow.data.investing}} etc.

Thanks in advance for the help, cheers!

Hi kevinTDS!

Could you share an example of a return value from your JS query? I'm not sure I follow exactly what you are trying to do here!

Depending on what your output is, you might need to cast the value to be an int. Something like CAST({{MyJSQueryResult}} AS INT) . I grabbed an example of this from Stackoverflow