Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Taking entries from database containing %

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Naveen Mishra
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same is true for Oracle and DB2 as well.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!