The WHERE in SQL applies to a specific SELECT ; for the whole UNION you cannot specify WHERE .
In addition, you indicate that the table structure is different, and UNION requires that all subqueries return the same number of columns with the same data types. Therefore, it is inadmissible to use * in the select list, it is necessary to enumerate explicitly those columns that each of the subqueries must return and their number / types must match.
So your request should look something like this:
SELECT col1, col2, col3 FROM category_tree WHERE url = :url UNION SELECT col1, col2, col3 FROM pages WHERE url = :url
In principle, you can of course UNION from two tables without the conditions of the sample to enclose in brackets and make an external SELECT for which it will be in FROM , but I do not cite this option, since it is not recommended to do so categorically since the query optimizer in this case will not be able to correctly apply indexes, even if they exist, will apply the connection of all tables at a time and the query execution time and the server load will be very large.