Wildcard

  • sknox (2/1/2010)


    To be strict, the source data was a red herring. A where clause shouldn't be based on the data you have, but the data you want.

    In this case, for example, it doesn't matter that "Jim" exists in the source data (or "Tim" or "Kim" or "Bim" for that matter). What matters is that you want to retrieve only rows with "Tim" or "Kim".

    If you used "Like '%im'", and "Jim" wasn't in the source data, your query would work. Once. But it would break as soon as someone added any other name like '%im'. If you get in the habit of using shortcuts rather than framing your query properly, you'll be rewriting queries more and more often.

    Trust me, I know.

    Yes, I agree. Now if one of the answers offered had been [^J]im I wonder if anyone would haven fallen into the trap of giving an answer that would work with the given data but not in general - then the source data would have been a real red herring!

    It was a good question and answer, anyway.

    Tom

  • Thanks for asking one I know without having to think about 🙂

    Peter Trast
    Microsoft Certified ...(insert many literal strings here)
    Microsoft Design Architect with Alexander Open Systems

  • Nice easy one - thanks 🙂

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply