Filtering 2 tables with the value of one inputfield

I have one autocomplied input.
and I have two tables in one database:
table 1 with materials
table 2 with models.

Now the task:

you can fill the input with values of material or models:
e.g. you write “wool” (material) it’s autocompleted with all materials contains “wool”
but if you write “x-123” then all models have to been shown containing (or starting with) the expression
the select value has to be stored in a variable for further use in the queries.

In the repeating zone of the document should be shown the results of the queries.

I have no clue how to solve this problem.

Thanks in advance

You would likely need to results tables on your page and show or hide based on if they have values or not.

This is a good idea, but it solves only half of the problem. In the input field is only one link to a value and text field possible. Though there is only one Input possible :material or model, but not both.