DEV Community

Discussion on: What was your win this week?

Collapse
 
annarankin profile image
Anna Rankin

This week, I learned about using NOT EXISTS in a SQL subquery! I was able to use this to get rid of a left join and speed up a hairy database query 🎉🎉🎉 It really made my week lol. Also had a really good chat with a mentee about equivalence vs. equality in JS and Ruby!

insert-gif

Collapse
 
dmfay profile image
Dian Fay

I wish SQL had a negative join operation consistent with other join types because the fact that a NOT EXISTS subquery outperforms the outer join + null test approach just doesn't seem right.

Collapse
 
annarankin profile image
Anna Rankin

I absolutely agree - I actually found this by googling "opposite of a join query" 😂 it would be cool to have an EXCLUDE operation or something similar