I would like to know how to make a single query to select something from one table or from another. For example I have Table A with the aID=2 and Table B with bID=3. So how to make the query to return the id from table A or table B for a given id = 3?
Thanks in advance
If you do not know which table to use before you’re running the query, you can combine multiple queries with
UNION, provided that you’re selecting the same number of columns:If you do not want to duplicate the WHERE condition, you can use a nested query and apply the WHERE to its result: