Results 1 to 4 of 4

Thread: Sql pattern matching with <sql:query> tags?

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Sql pattern matching with <sql:query> tags?

    Any one know how to use sql pattern matching with the <sql:query> tags?
    I have the following simple query. After adding in the '%' tomcat wasen't too happy . Is there a work around? Thanks.
    Code:
     <sql:query var="empDbInfo">
        SELECT * from employees Where fname like = ?
        <sql:param value = "${param.fname}%"/>
     </sql:query>

  2. #2

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Sql pattern matching with <sql:query> tags?

    I tried the following but still get a syntax error.
    Code:
    <sql:query var="empDbInfo">
        SELECT * from employees Where fname like = ? + "%"
        <sql:param value = "${param.fname}"/>
     </sql:query>

  3. #3
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Sql pattern matching with <sql:query> tags?

    NoteMe answers blind folded .

    Never tried. But when I do it in PHP, I keep trying with escaping characters like that with / or adding ' ' around it and stuff. Have you tried that too?


    ØØ

  4. #4

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Sql pattern matching with <sql:query> tags?

    If i leave the like in which is the right sql syntax i get an error. If i take the like out and end up with SELECT * from employees Where fname = ? + "%" the .jsp page compiles fine but when the submit button is hit the query pulls up every record. Even if the param <sqlaram value = "${param.fname}"/> does not contain a value or contains a value that does not match a name in the db.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width