SELECT and check if exist column in another table