Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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, > whether MySQL has a LIKE operator, and why none > of the victims' initials are 'R L'.

For the record since you never see the entire query so it is likely that the SQL is not as wrong as the author suggests. There is an extensive use of ORs in the query so the conditions that are said to defeat the outer joins are not mandatory and the 'R' and 'L' checks are clearly not required to pass. I think it is pretty good representation of how you might build up query from scratch, piling up conditions in OR clauses to finally get what you want. Yes, provided the table that starts with V is aliased as v the v.SEX condition does defeat the outer join, but that might be exactly the sort of thing you would stick in after you had already established a working FROM clause and not bother changing the outer to an inner. Solving the case was after all by definition a one-off.

I enjoyed this article because it points out an occasion where a movie really did try to get it right. Someone who knows something about databases had to have made those screens up.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: