Alternatives to LIKE %word

  • I am trying to find other alternatives to LIKE '%word' search clause so I that I would not need to use wildcard.

    Here is what I came up:

    Select OriginatingID

    FROM m

    Where LEFT(OriginatingID, 4) = ANY (SELECT OrigID FROM tmpO)

    tmpO table has 4 character strings that needs to be compared against last four character strings in m table. LEFT(OriginatingID, 4) should give a column of four character strings to comapre against. but it doesn;t work.... any ideas

  • The alternative to

    where field like '%word' is

    where RIGHT(field,4) = 'word'

    LEFT(field,4) gets the first four characters of field, not the final four.

    Regards

    Phil

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Well, since both methods can't use an index anyway, don't expect good performance on larger tables. I'm not that much into Full-Text Searching, however it might be an idea to read about it in BOL.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • I've found that using string functions in WHERE clauses has a higher performance penalty than using LIKE with wildcards.

Viewing 4 posts - 1 through 3 (of 3 total)

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