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. Sql server like clause

Sql server like clause

Scheduled Pinned Locked Moved Database
databasesql-serversysadmin
6 Posts 5 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.
  • R Offline
    R Offline
    rubonkumar
    wrote on last edited by
    #1

    insert into rk_process (code,name,label) values ('01','lee001','aa' ) insert into rk_process (code,name,label) values ('01','lee002','aa' ) insert into rk_process (code,name,label) values ('01','lee003','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) want to filter only (lee) but it showing (leek) also select name from rk_process where name like '%lee%') thanks in advance. Result

    lee001
    lee002
    lee003
    leek001
    leek001

    but i need only

    lee001
    lee002
    lee003

    L P R 3 Replies Last reply
    0
    • R rubonkumar

      insert into rk_process (code,name,label) values ('01','lee001','aa' ) insert into rk_process (code,name,label) values ('01','lee002','aa' ) insert into rk_process (code,name,label) values ('01','lee003','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) want to filter only (lee) but it showing (leek) also select name from rk_process where name like '%lee%') thanks in advance. Result

      lee001
      lee002
      lee003
      leek001
      leek001

      but i need only

      lee001
      lee002
      lee003

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You specified in your like clause that you want any words with "lee" so that is what you get. Try "lee0" so it will not get those containing the 'k'.

      One of these days I'm going to think of a really clever signature.

      1 Reply Last reply
      0
      • R rubonkumar

        insert into rk_process (code,name,label) values ('01','lee001','aa' ) insert into rk_process (code,name,label) values ('01','lee002','aa' ) insert into rk_process (code,name,label) values ('01','lee003','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) want to filter only (lee) but it showing (leek) also select name from rk_process where name like '%lee%') thanks in advance. Result

        lee001
        lee002
        lee003
        leek001
        leek001

        but i need only

        lee001
        lee002
        lee003

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Not tested, but off-hand... '%lee[0-9]%' or '%lee[^k]%' P.S. You didn't specify which database system you are using. And you probably don't need the leading percent sign (%)

        M R 2 Replies Last reply
        0
        • P PIEBALDconsult

          Not tested, but off-hand... '%lee[0-9]%' or '%lee[^k]%' P.S. You didn't specify which database system you are using. And you probably don't need the leading percent sign (%)

          M Offline
          M Offline
          Mike Meinz
          wrote on last edited by
          #4

          Tested: select name from rk_process where name like '%lee[0-9]%' Yields: lee001 lee002 lee003

          1 Reply Last reply
          0
          • P PIEBALDconsult

            Not tested, but off-hand... '%lee[0-9]%' or '%lee[^k]%' P.S. You didn't specify which database system you are using. And you probably don't need the leading percent sign (%)

            R Offline
            R Offline
            rubonkumar
            wrote on last edited by
            #5

            thank you so much PIEBALDconsult

            1 Reply Last reply
            0
            • R rubonkumar

              insert into rk_process (code,name,label) values ('01','lee001','aa' ) insert into rk_process (code,name,label) values ('01','lee002','aa' ) insert into rk_process (code,name,label) values ('01','lee003','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) insert into rk_process (code,name,label) values ('01','leek001','aa' ) want to filter only (lee) but it showing (leek) also select name from rk_process where name like '%lee%') thanks in advance. Result

              lee001
              lee002
              lee003
              leek001
              leek001

              but i need only

              lee001
              lee002
              lee003

              R Offline
              R Offline
              rajarao304
              wrote on last edited by
              #6

              by using this query you can achive you require output select * from rk_process where name like '%lee0%' --raj :-O

              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