Seems you want an indicator if a Name exists in Name1 or Name2, but your result doesn't match.
SELECT name, MAX(Name1), MAX(Name2)
FROM
(
SELECT name1 AS name, 'Y' AS Name1, 'N' AS Name2 FROM table1
UNION ALL
SELECT name2, 'N', 'Y' FROM table1
) AS dt
GROUP BY 1
Seems you want an indicator if a Name exists in Name1 or Name2, but your result doesn't match.