Help with an OR query

  • Hi All,

    Am hoping someone can help with this as it's turning me grey!

    I have this query currently:

    select updatedb.callref, updatedb.updatetxt, updatedb.udsource, opencall.suppgroup

    from updatedb

    left join opencall

    on updatedb.callref=opencall.callref

    where udindex = '0'

    and suppgroup = 'SUPPORT'

    and (updatetxt like '%' + @Word + '%')

    and opencall.status <> '17'

    This means that when they search for items and they separate each word it is "and" between each one.

    They would like it to be more fuzzy with "and" and "or". How can I adapt this?

    You will save me from tearing more of my hair out more than I have!

    Thank you in advance.

  • Could you be a bit more specific about what 'they' want?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Apols perhaps I wasn't clear.

    What they (management) want to be able to do is search on the initial description from the user to find out how many calls were raised for a specific theme. For example if the website is down, or on a virus issue. So they would like to enter the word "virus" and get all emails that were raised on this topic.

    Currently if management put in more than one word it pulls up only the calls raised with both words in the emails. What they want is to have a search where all calls will be pulled for all the words in there. So or rather than and.

    Is that clearer? The calls are raised if there is an issue with the website so if there are a couple of interlinked themes they want to capture the details of all calls that were raised for this.

  • Full text is just the option designed for what you are looking for http://technet.microsoft.com/en-us/library/ms142571(v=sql.105).aspx

  • That's what i have understand so far.

    Input string : John Smith

    on the basis of this you need something like this

    Where Name like '%John%' OR Name like '%Smith%'

    Am i right about this ?

  • Thanks SSC will take a read!

    Twin Devil yep, only they need to be able to specify as many words as they want, hence why the query is the way it is. If management want to search on 20 words then that's what they want.

  • That's damn hard to do in SQL Server. Full text will probably be your best bet, but likely to be hard even with that.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • karen.blake (10/17/2014)


    Thanks SSC will take a read!

    Twin Devil yep, only they need to be able to specify as many words as they want, hence why the query is the way it is. If management want to search on 20 words then that's what they want.

    Looks more like a wishlist then a requirement. As the GREATS (Management) wants it.

    Anyways, as suggested you should better look in FULL TEXT. check this link[/url].

    It would give you a head start.

  • Thanks all, really appreciated!

Viewing 9 posts - 1 through 8 (of 8 total)

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