Quote:
if table A exist then choose table A else Table B
The code you've shown would do the opposite - it will only return the record from table A if there isn't a matching record in table B.
Try something like this:
SELECT
id,
name,
age
FROM
TableA
UNION ALL
SELECT
id,
name,
age
FROM
TableB As b
WHERE
NOT EXISTS
(
SELECT *
FROM TableA As a
WHERE a.id = b.id
)
;