Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Help needed for a serach condition in sql [modified]

Help needed for a serach condition in sql [modified]

Scheduled Pinned Locked Moved Database
questioncsharpdatabasealgorithmshelp
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naveed Kamboh
    wrote on last edited by
    #1

    Hi Friends, I have a data like in a name field like below Martins Martin's how can I get both record when some one passes in search input string only Martins i.e if I pass Martins It should return both Martins and Martin's it is a specific case, think in general where uer will pass Martins not Martin. johns not john only can i remove ( ' ) it from field in where condition if yes then how? If you need further explination please do not hesitate to ask.

    Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

    modified on Thursday, May 15, 2008 8:25 AM

    B P 3 Replies Last reply
    0
    • N Naveed Kamboh

      Hi Friends, I have a data like in a name field like below Martins Martin's how can I get both record when some one passes in search input string only Martins i.e if I pass Martins It should return both Martins and Martin's it is a specific case, think in general where uer will pass Martins not Martin. johns not john only can i remove ( ' ) it from field in where condition if yes then how? If you need further explination please do not hesitate to ask.

      Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

      modified on Thursday, May 15, 2008 8:25 AM

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      select [name] from myTable where [name] like '%Martin%'


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      1 Reply Last reply
      0
      • N Naveed Kamboh

        Hi Friends, I have a data like in a name field like below Martins Martin's how can I get both record when some one passes in search input string only Martins i.e if I pass Martins It should return both Martins and Martin's it is a specific case, think in general where uer will pass Martins not Martin. johns not john only can i remove ( ' ) it from field in where condition if yes then how? If you need further explination please do not hesitate to ask.

        Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

        modified on Thursday, May 15, 2008 8:25 AM

        P Offline
        P Offline
        Piyush Vardhan Singh
        wrote on last edited by
        #3

        Use like operator like this: Select * from tablename where name like 'martin%'

        Piyush Vardhan Singh p_vardhan14@rediffmail.com http://holyschoolofvaranasi.blogspot.com http://holytravelsofvaranasi.blogspot.com

        1 Reply Last reply
        0
        • N Naveed Kamboh

          Hi Friends, I have a data like in a name field like below Martins Martin's how can I get both record when some one passes in search input string only Martins i.e if I pass Martins It should return both Martins and Martin's it is a specific case, think in general where uer will pass Martins not Martin. johns not john only can i remove ( ' ) it from field in where condition if yes then how? If you need further explination please do not hesitate to ask.

          Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

          modified on Thursday, May 15, 2008 8:25 AM

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          select * from myTable where soundex(ColValue) = soundex('john''s')


          I Love T-SQL "Don't torture yourself,let the life to do it for you."

          N 1 Reply Last reply
          0
          • B Blue_Boy

            select * from myTable where soundex(ColValue) = soundex('john''s')


            I Love T-SQL "Don't torture yourself,let the life to do it for you."

            N Offline
            N Offline
            Naveed Kamboh
            wrote on last edited by
            #5

            select organisationname from organisation where soundex(organisationname) = soundex('martins') I used your query , my question was if Input martins it also return record including martin and martin's. so its not returnt record which have martin's in it.

            Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

            B 1 Reply Last reply
            0
            • N Naveed Kamboh

              select organisationname from organisation where soundex(organisationname) = soundex('martins') I used your query , my question was if Input martins it also return record including martin and martin's. so its not returnt record which have martin's in it.

              Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              I have tested by giving input string 'martins' and 'martin''s' and query returns two rows with values martin and martin's (those values are stored on database). select organisationname from organisation where soundex(organisationname) = soundex('martins') and the next query gives me same result select organisationname from organisation where soundex(organisationname) = soundex('martin''s')


              I Love T-SQL "Don't torture yourself,let the life to do it for you."

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups