sql select

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jemy

    sql select

    Hi all, I need to do a keyword search against database table (MSSQL 2000) on
    particular field/column, say the keyword: "sql server 2000". The search
    should return without any order restrictions, so it might return result
    contain '2000' and 'sql' and 'server', or can return that contain 'server'
    only. appreciate any advice.
    thanks from Jemy.


  • David Portas

    #2
    Re: sql select

    SELECT ...
    FROM YourTable
    WHERE col LIKE '%sql%'
    OR col LIKE '%server%'
    OR col LIKE '%2000%'

    --
    David Portas
    SQL Server MVP
    --


    Comment

    • Jemy

      #3
      Re: sql select

      Thanks David,
      Im thinking if there are any other resorts to this using regular expression
      in sql select, and if possible results are returned in order of preference
      (from mostly match).
      Im not sure why I want to use other resort, but it seems using mix 'or' and
      'and' doesnt return closest match result.


      "David Portas" <REMOVE_BEFORE_ REPLYING_dporta s@acm.org> wrote in message
      news:MqSdnV7CXv v4x6DcRVn-hA@giganews.com ...[color=blue]
      > SELECT ...
      > FROM YourTable
      > WHERE col LIKE '%sql%'
      > OR col LIKE '%server%'
      > OR col LIKE '%2000%'
      >
      > --
      > David Portas
      > SQL Server MVP
      > --
      >
      >[/color]


      Comment

      • Erland Sommarskog

        #4
        Re: sql select

        Jemy (cutejemy@REMOV Ehotmail.com) writes:[color=blue]
        > Im thinking if there are any other resorts to this using regular
        > expression in sql select, and if possible results are returned in order
        > of preference (from mostly match). Im not sure why I want to use other
        > resort, but it seems using mix 'or' and 'and' doesnt return closest
        > match result.[/color]

        There are no regular expressions in SQL like in, say, Perl, so David's
        suggestion is about the best you can get, unless you want to explore
        full-text indexing.




        --
        Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

        Books Online for SQL Server SP3 at
        SQL Server 2025 redefines what's possible for enterprise data. With developer-first features and integration with analytics and AI models, SQL Server 2025 accelerates AI innovation using the data you already have.

        Comment

        Working...