PDA

Click to See Complete Forum and Search --> : Sql pattern matching with <sql:query> tags?


Dillinger4
Mar 6th, 2005, 11:04 PM
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 :lol:. Is there a work around? Thanks.

<sql:query var="empDbInfo">
SELECT * from employees Where fname like = ?
<sql:param value = "${param.fname}%"/>
</sql:query>

Dillinger4
Mar 7th, 2005, 11:53 AM
:sick: I tried the following but still get a syntax error.

<sql:query var="empDbInfo">
SELECT * from employees Where fname like = ? + "%"
<sql:param value = "${param.fname}"/>
</sql:query>

NoteMe
Mar 9th, 2005, 05:37 AM
NoteMe answers blind folded :cool: .

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?


ии

Dillinger4
Mar 9th, 2005, 01:14 PM
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 <sql:param value = "${param.fname}"/> does not contain a value or contains a value that does not match a name in the db.