my dog learned polymorphism
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


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Taking entries from database containing %" Watch "Taking entries from database containing %" New topic
Author

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
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3749
    
  10

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: http://aspose.com/file-tools
 
subject: Taking entries from database containing %
 
jQuery in Action, 3rd edition