Select clause based on one table (WHERE)