Fellow Monks... maybe not a truly perl perl question... but the solution will be in Perl so I dont feel so Guilty...

So take this simple example, I have a table in my database which is full of city names which mate to IATA codes.. for instance

London = LON Miami = MIA Paris = PAR

So we have a user comes in and enters London... great so we do a select where city name = 'London'.... but then the user cunningly enters London, UK... which of course my original select wont work.... nor would any like statements..

So... maybe I use Soundex... (mysql Soundex in this case)... so I use said function... and so I check this and I get..

select soundex('London'), soundex('London, UK')

Which gives me L535 and L5352... so getting better...maybe do some comparison of first X bits ??

Then I look at user entering UK - London... Soundex not going to like that coming back with U24535...

Now I could take to the next point of no matches... so I split it... but on what ? use could enter spaces, - ',' etc etc...

Now dont get me wrong I can deal with the majority of the cases using likes, soundexs.... but maybe there is a better way ??

In reply to Matching in the Database... by ropey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.