How to add dynamic values to query in workflows

I think you would need to disable prepared statements for the resource. There is some discussion on this in the below link (though for apps, I would guess it works for workflows too). Buyer beware in regards to opening up the danger of SQL injection in doing so.

One other thought would be a branch in the code that is used to direct toward one table or another. This would get exceedingly complicated and difficult to maintain if the number of possible tables is large (more than two, IMO :person_shrugging:).