AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LIKE escape clause for JDBC

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Mike DiChiappari
Guest





PostPosted: Tue Apr 10, 2007 5:48 pm    Post subject: LIKE escape clause for JDBC Reply with 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. 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





PostPosted: Tue Apr 10, 2007 5:59 pm    Post subject: Re: LIKE escape clause for JDBC Reply with quote



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





PostPosted: Mon Apr 16, 2007 5:28 pm    Post subject: Re: LIKE escape clause for JDBC Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.