Suppose there are two tables, provided that the columns in them are identical, but the id in them is unique, i.e. in table 1 there can be no id which already exists in table 2. I have a certain value, I need to determine in which table it is located, I write a query with the union of two tables for its search
SELECT t.id FROM ( SELECT id FROM table_1 UNION SELECT id FROM table_2 ) as t WHERE t.id = "22" The query works, and I can get the result - there is a given value in which of the tables or not. The task is in this way, I pass a certain value and if there is one, then get the name of the table in which it is located. 