BBAA
BBAA

Reputation: 55

left/right join

I got 2 tables like this:

C1 
1   
1   
2   

And this is table 2

C1  C2
1   x
1   y
2   y

And I want that the result is:

C1 C2
1  x
2  null

I don't want to see Y but I need to see 2 for other information.

With left join it shows also null by 1 and with right join 2 wont show.

Upvotes: 1

Views: 81

Answers (1)

Matthias Meid
Matthias Meid

Reputation: 12521

Try this, assuming the column names match the table names:

SELECT C1.C1, C2.C2
  FROM C1
    LEFT JOIN C2 ON C2.C1 = C1.C1 AND C2.C2 <> 'y'

I'm not sure whether this is your actual requirement. You may tell us some more details about what you're actually trying to achieve.

Upvotes: 2

Related Questions