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 Query

SQL Query

Scheduled Pinned Locked Moved Database
databasehelptutorialquestion
8 Posts 6 Posters 1 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.
  • U Offline
    U Offline
    uspatel
    wrote on last edited by
    #1

    How to fetch records as OTH IA LE from table using Like query without using OR.as select *from Issue where ReqControlNo like '%i%' or ReqControlNo like '%h%' or ReqControlNo like '%l%' query should be as select *from Issue where ReqControlNo like 'condition' the condition should be in one string. is there any solution please?

    L P L N G 5 Replies Last reply
    0
    • U uspatel

      How to fetch records as OTH IA LE from table using Like query without using OR.as select *from Issue where ReqControlNo like '%i%' or ReqControlNo like '%h%' or ReqControlNo like '%l%' query should be as select *from Issue where ReqControlNo like 'condition' the condition should be in one string. is there any solution please?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      That's a task for the Union. :)

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      1 Reply Last reply
      0
      • U uspatel

        How to fetch records as OTH IA LE from table using Like query without using OR.as select *from Issue where ReqControlNo like '%i%' or ReqControlNo like '%h%' or ReqControlNo like '%l%' query should be as select *from Issue where ReqControlNo like 'condition' the condition should be in one string. is there any solution please?

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

        Is this SQL server? Recently I wrote a CLR Scalar Function that uses RegEx to do that, that might be the sort of thing you need. I doubt it's easily doable with straight SQL.

        U 1 Reply Last reply
        0
        • U uspatel

          How to fetch records as OTH IA LE from table using Like query without using OR.as select *from Issue where ReqControlNo like '%i%' or ReqControlNo like '%h%' or ReqControlNo like '%l%' query should be as select *from Issue where ReqControlNo like 'condition' the condition should be in one string. is there any solution please?

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

          Uma Shankar Patel wrote:

          the condition should be in one string.

          Could you explain that? To me, the conditional filter is the entire WHERE clause. Are you by any chance looking for the full-text search[^]?

          Bastard Programmer from Hell :suss:

          1 Reply Last reply
          0
          • P PIEBALDconsult

            Is this SQL server? Recently I wrote a CLR Scalar Function that uses RegEx to do that, that might be the sort of thing you need. I doubt it's easily doable with straight SQL.

            U Offline
            U Offline
            uspatel
            wrote on last edited by
            #5

            yes. it is Sql Server. Actually ,I want to search those records that have i ,l or h. I want put the string in database.as %comm% for Records that have comm. %crd% for records that have crd. same way i want to store the string for i,l and h.in one string.

            1 Reply Last reply
            0
            • U uspatel

              How to fetch records as OTH IA LE from table using Like query without using OR.as select *from Issue where ReqControlNo like '%i%' or ReqControlNo like '%h%' or ReqControlNo like '%l%' query should be as select *from Issue where ReqControlNo like 'condition' the condition should be in one string. is there any solution please?

              N Offline
              N Offline
              Niladri_Biswas
              wrote on last edited by
              #6

              Try this Declare @t table (Record Varchar(20)) Insert Into @t Select 'OTH' Union All Select 'IA' Union All Select 'LE' Union All Select 'xxx' Select * From @t Where Record like '%[H,A,E]%' /* Result */ Record OTH IA LE Hope this helps Thanks in advance

              Niladri Biswas

              1 Reply Last reply
              0
              • U uspatel

                How to fetch records as OTH IA LE from table using Like query without using OR.as select *from Issue where ReqControlNo like '%i%' or ReqControlNo like '%h%' or ReqControlNo like '%l%' query should be as select *from Issue where ReqControlNo like 'condition' the condition should be in one string. is there any solution please?

                G Offline
                G Offline
                Ganu Sharma
                wrote on last edited by
                #7

                You already have best solution.

                U 1 Reply Last reply
                0
                • G Ganu Sharma

                  You already have best solution.

                  U Offline
                  U Offline
                  uspatel
                  wrote on last edited by
                  #8

                  Finally I have achieve this by select *from Issue where ReqControlNo like '[ilh]%'

                  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