PostgreSQL query where column is represented as a string

56 views Asked by At

I'm using Retool, and trying to run a query where the column value comes from a drop-down list. The value output is a string, so my query looks like this:

select * from accounts where {{dropDownList.value}} ilike {{'%' + account_search_textInput.value + '%'}}

When the query runs, it is as follows:

select * from accounts where "first_name" ilike '%Adam%';

The double quotes around the column name first_name seem to be causing an issue but I don't think I can remove them. Is there any other way to successfully run the query where first_name can represent the column name rather than a string value?

0

There are 0 answers