Try going to Resources --> Hover over retool database and click setting (on the right) --> enable "Disable converting queries to prepared statements".
I think then your first attempt should work. Otherwise you can also return an Array from a javascript have the column name at index 0 and value at index 1 and do something like where {{array[0]}} = {{array[1]}}