File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Taking entries from database containing % Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Taking entries from database containing %" Watch "Taking entries from database containing %" New topic

Taking entries from database containing %

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I want to take entries from database having % ,how to do that
I am doing:
select * from tablename where columnname like '%%'
but not working
How can i achieve that
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

I believe it varies on the DBMS but since % is a special character, if you want to reference it as a literal you need to use something like \% (MySQL usage).

For example if you wanted to find all rows with a column that contains a %, the query would be:

Note the % before and after \% for wildcard matching.

[OCA 8 Book] [Blog]
Naveen Mishra
Ranch Hand

Joined: Nov 20, 2005
Posts: 75
The same is true for Oracle and DB2 as well.
I agree. Here's the link:
subject: Taking entries from database containing %
It's not a secret anymore!