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. Pass wild card value to Where Like Statement.

Pass wild card value to Where Like Statement.

Scheduled Pinned Locked Moved Database
databasecsharpbeta-testingcode-review
4 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.
  • J Offline
    J Offline
    japel
    wrote on last edited by
    #1

    I have the below query but would like to use a wild card value to do the search. I need to pass a value like "on" and find, Jason or Preston. It would be nick if it is also not case sensitive.... This value is coming from VB.Net App and this is messing with me... My Access (SQL) statement is: SELECT * FROM MainTB WHERE myCustomer Like [@myVar]; But the LIKE needs to be [%myVar%] I think. Feedback welcome please......

    When people make you see red, be thankful your not colour blind.

    A C 2 Replies Last reply
    0
    • J japel

      I have the below query but would like to use a wild card value to do the search. I need to pass a value like "on" and find, Jason or Preston. It would be nick if it is also not case sensitive.... This value is coming from VB.Net App and this is messing with me... My Access (SQL) statement is: SELECT * FROM MainTB WHERE myCustomer Like [@myVar]; But the LIKE needs to be [%myVar%] I think. Feedback welcome please......

      When people make you see red, be thankful your not colour blind.

      A Offline
      A Offline
      albCode
      wrote on last edited by
      #2

      SELECT * FROM MainTB WHERE myCustomer Like ('%myVar%');

      J 1 Reply Last reply
      0
      • A albCode

        SELECT * FROM MainTB WHERE myCustomer Like ('%myVar%');

        J Offline
        J Offline
        japel
        wrote on last edited by
        #3

        Running this query from access it does not ask me for an input it is looking for a user of %myVar% As it is in the ' ' string quotes... I have already found this and tryed it... Any other thoughts..... ?

        When people make you see red, be thankful your not colour blind.

        1 Reply Last reply
        0
        • J japel

          I have the below query but would like to use a wild card value to do the search. I need to pass a value like "on" and find, Jason or Preston. It would be nick if it is also not case sensitive.... This value is coming from VB.Net App and this is messing with me... My Access (SQL) statement is: SELECT * FROM MainTB WHERE myCustomer Like [@myVar]; But the LIKE needs to be [%myVar%] I think. Feedback welcome please......

          When people make you see red, be thankful your not colour blind.

          C Offline
          C Offline
          Chris Meech
          wrote on last edited by
          #4

          The string concatenation character might help

          select *
          from MainTB
          where upper(myCustomer) like '%'|upper(@myVar)|'%'

          This will also make it case insensitive.

          Chris Meech I am Canadian. [heard in a local bar] Nobody likes jerks. [espeir] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

          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