| View previous topic :: View next topic |
| Author |
Message |
Mike DiChiappari Guest
|
Posted: Tue Apr 10, 2007 5:48 pm Post subject: LIKE escape clause for JDBC |
|
|
I want to do something like:
SELECT * FROM Person WHERE lastname LIKE 'Smit%' or with a PreparedStatement
something a little more dynamic, such as
SELECT * FROM Person WHERE lastname LIKE ?%
I've seen numerous explanations of how to "escape" the percent sign through
JDBC. Following those examples I've tried:
SELECT * FROM Person WHERE lastname LIKE ?$% {escape $}
SELECT * FROM Person WHERE lastname LIKE '?$%' {escape $}
The problem is those don't work. Any help would be appreciated.
Mike |
|
| Back to top |
|
 |
Tom Hawtin Guest
|
Posted: Tue Apr 10, 2007 5:59 pm Post subject: Re: LIKE escape clause for JDBC |
|
|
Mike DiChiappari wrote:
| Quote: | I want to do something like:
SELECT * FROM Person WHERE lastname LIKE 'Smit%' or with a PreparedStatement
something a little more dynamic, such as
SELECT * FROM Person WHERE lastname LIKE ?%
|
Append the '%' to the string either within Java or SQL (LIKE CONCAT(?,
'%')).
Tom Hawtin |
|
| Back to top |
|
 |
Lionel Guest
|
Posted: Mon Apr 16, 2007 5:28 pm Post subject: Re: LIKE escape clause for JDBC |
|
|
Mike DiChiappari wrote:
| Quote: | I want to do something like:
SELECT * FROM Person WHERE lastname LIKE 'Smit%' or with a
PreparedStatement something a little more dynamic, such as
SELECT * FROM Person WHERE lastname LIKE ?%
I've seen numerous explanations of how to "escape" the percent sign
through JDBC.
|
This works with Oracle:
SELECT * FROM Person WHERE lastname LIKE 'Smit!%' |
|
| Back to top |
|
 |
|