If I understand your setup correctly, why not try making a second query to fetch the name_of_product for the selected id in Dropdown #1?
Here’s how the query would look:
SELECT name_of_product
FROM your_table
WHERE parent_id IN (:list_of_ids);
Example
If your list of parent_ids is [1, 2, 3], the query would become:
SELECT name_of_product
FROM your_table
WHERE parent_id IN (1, 2, 3);
Hey @andrew.prshkv,
You can either do as @amer pointed out, or you can use query join syntax to fetch data from your products table in the main table (in this case you only need to fetch from one table).
You can get more details here:
and here a demo page that showcase how to use query join