FROM table join table2 using(table1_ID)
ot1 as table, offtable1.fkey as fkey, other, stuff from offtable_1
ot2 as table, offtable2.fkey as fkey, other, stuff from offtable_2
) dt ON dt.fkey = table.key
where concat(other, stuff) like '%I didn't try really hard on this one%';
Not going to be pretty. You can sure do it though, but consider trying to normalize the data more. It just seems to me like you want nice pretty joins, but you have not normalized your data at all and fallen back onto something where you just make a table to put data into the db really quicky even if it doesn't make sense. shrug, maybe not. I haven't really seen your database, so I don't know.
From my experience, creating a function that is not 100% non-deterministic doesn't do much for you. You can almost always, it seems, write it into the query in a way that's much faster. A function for something like an
ordinal suffix makes sense, but a function for joining your table's doesn't make much sense to me- not when a parameter is going to be the name of the table you're joining.