Building a query to find partial (but close) matches in 2 differents tables

I would like to search for partial (but closes) matches for terms in 2 differents tables (specific cells) and show the associated lines data.


In table 1, in the choosen column for this query, there is a cell with 'behind the word mountains'
In table 2, in the choosen column there is a cell with 'behind words mountains'

I would like to output both cells thats match, along all data on the same line for both tables.

Is retool the right toll for this?

I have the date in a google sheets. But exporting to SQL is not a problem.

Hey there @Reversal8023, by different tables, do you mean the schema is different for both?

If they are not, you can combine both using Query JSON with SQL resource like:

FROM {{ }} a
FROM {{ }} b

You can use that now as a subquery and add the filter on the outer query.

If they are, you can do the same thing as above but by specifying the column of what you want to filter and an accompanying identifier that's unique for when you combine both.

Yep, 2 tables and joining is fine. But how to set the query after to get this?


By the way, I think it would be best if it would come with an intelligent search with precision score with with . Something like this:

@Reversal8023 I didn't mean join. I meant UNION so that you'll only have 2 columns still, not 4. Once you have that UNIONed data, you can address the precision score in a JS Query by creating a Levenshtein function (I used this one here). Unioning it means that you'll only focus and manipulate that single column which you can use as first param in the similarity function below and the second param be the search term you want to use.

Copy pasta that in a JS Query and then add that column in your Union query output:


Just to note on the above, I used norh dakta as my search word in textInput3.value.

You can specify the timing for this one. Since you are using a JS function, better that it'll be outputted by a JS Query. Instead of a UNION SQL Query, you can also do this directly in JS by using concat method, i.e.:

var dat1 =
var dat2 = =

You can read more on array concatenation from this answer.