Hacker News new | ask | show | jobs
by Morg 5129 days ago
For people using mysql, that kind of query really isn't such bad SQL at all.
1 comments

Shocked moviegoers will have been left wondering why a genius-level hacker would outer-join to the Victims and Keywords tables only to use literal-text filter predicates that defeat the outer joins

Any excuse for this? :)

The MySQL optimizer will actually notice and remove the outer join aspect automatically. So I have often done this out of pure laziness if I start with an outer join, but really end up needing an inner join.
Realistically that they started the query with keywords optional, then moved to them being required (which, it should be noted, a good query planner would effective make an inner join). On the scale of evils of SQL, it lies somewhere around "friendly benign".