SQl question

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

    SQl question

    Hi,

    Is there any sql command which can find defined text in specific fields. For
    example I have a table with names like "Ivan Sammut" etc. Now I want to
    create a statment which select all those records which contain the text
    "Ivan" or those that contain the text "Sammut". Is there a way I can achieve
    this with an SQL statement.

    Ivan



  • Landi

    #2
    Re: SQl question

    wrong newsgroup

    try microsoft.publi c.sqlserver.pro gramming

    --
    info@donotspam dowhileloop.com
    http://www.dowhileloop.com web development
    http://publicjoe.dowhileloop.com -- C# Tutorials

    "Ivan Sammut" <sammuts@nextge n.net.mt> wrote in message
    news:O6ZWjJyTFH A.1432@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi,
    >
    > Is there any sql command which can find defined text in specific fields.[/color]
    For[color=blue]
    > example I have a table with names like "Ivan Sammut" etc. Now I want to
    > create a statment which select all those records which contain the text
    > "Ivan" or those that contain the text "Sammut". Is there a way I can[/color]
    achieve[color=blue]
    > this with an SQL statement.
    >
    > Ivan
    >
    >
    >[/color]


    Comment

    • Michael Voss

      #3
      Re: SQl question

      Hi!

      Ivan Sammut wrote:

      [...snip...][color=blue]
      > Is there any sql command which can find defined text in specific fields.[/color]
      For[color=blue]
      > example I have a table with names like "Ivan Sammut" etc. Now I want to
      > create a statment which select all those records which contain the text
      > "Ivan" or those that contain the text "Sammut". Is there a way I can[/color]
      achieve[color=blue]
      > this with an SQL statement.[/color]
      [...snip...]

      Your posting might yield better results in a sql newsgroup, but anyway:

      select
      *
      from
      yourtable
      where
      firstfield like '%Ivan%'
      or
      secondfield like '%Ivan%'
      or
      firstfield like '%Sammut%'
      or
      secondfield like '%Sammut%'
      ;

      You'll need to include every column you want to check into the where-clause.
      It might be a good idea to split the search into multiple select-statements
      in case you are searching for more words...


      Comment

      • Michael Voss

        #4
        Re: SQl question

        Landi wrote:

        [...snip...][color=blue]
        > try microsoft.publi c.sqlserver.pro gramming[/color]
        [...snip...]

        ....or the one of the countless sql newsgroups that is the most appropriate
        for the op's rdbms ;-)

        There is more out there than MS's SQLServer.

        SCNR
        Michael


        Comment

        Working...