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] Using 'Like' operator for prepared statement

[SQL] Using 'Like' operator for prepared statement

Scheduled Pinned Locked Moved Database
databasetutorialquestion
3 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.
  • P Offline
    P Offline
    ppp001
    wrote on last edited by
    #1

    Hi all, E.g "Select * from table_A where firstName Like '%" + string + "%'"; How to change the ad-hoc sql to prepared statement using operator 'like' and '%'? Thanks

    G C 2 Replies Last reply
    0
    • P ppp001

      Hi all, E.g "Select * from table_A where firstName Like '%" + string + "%'"; How to change the ad-hoc sql to prepared statement using operator 'like' and '%'? Thanks

      G Offline
      G Offline
      GreggS
      wrote on last edited by
      #2

      http://www.codeproject.com/script/comments/forums.asp?msg=1002675&forumid=1725#xx1002675xx[^]


      Gregg

      1 Reply Last reply
      0
      • P ppp001

        Hi all, E.g "Select * from table_A where firstName Like '%" + string + "%'"; How to change the ad-hoc sql to prepared statement using operator 'like' and '%'? Thanks

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

        How 'bout putting the wildcard character within the parameter?

        string strName = "%john%"
        string strSQL = "select * from table_A where firstName like ':PARAM'"

        Then assign to your parameter the value of strName. Chris Meech I am Canadian. [heard in a local bar] Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden] Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]

        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