No such thing as a small change | |
PerlMonks |
Re: s/Perl/SQL/ ?by roboticus (Chancellor) |
on Sep 10, 2012 at 14:22 UTC ( [id://992770]=note: print w/replies, xml ) | Need Help?? |
A join might be helpful, as you're guessing. Considering that it's using the same conditionals and tables, it would likely be good to refactor the SQL a bit. On first glance, it looks like you're using extremely similar conditions, so you could perhaps change it to:
I don't use mysql, but if it's like Oracle, then the "_" is a wildcard character, so effectively the first like expression is merely checking that the string is at least one character long, and the second checks that the string is at least 12 characters long with an 8 as the third-from-last character. The final like clauses could easily be converted to simple comparisons. So you could possibly gain a bit of speed (be sure to benchmark it!) by just doing the explicit checks:
Finally, to get rid of the trivial amount of embedded perl, you could use placeholders:
Update: Changed != to <> and substr to substring Re^4: s/Perl/SQL/ ? as described by Anonymous Monk. I didn't *fully* fix substring, as I've never seen nor tried the form "substring(A.foo from 1 for 2)". I don't doubt that it's correct (I even double-checked the SQL92 and SQL2002 docs referenced at http://savage.net.au/SQL/.) It's just too ugly for me to consider. ;^) ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|