wood burning stoves 2.0
The moose likes Oracle/OAS and the fly likes like keyword in sql 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 » Products » Oracle/OAS
Bookmark "like keyword in sql" Watch "like keyword in sql" New topic
Author

like keyword in sql

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 241
hey guys

iam using mysql
i need to pass a string to the LIKE keyword in sql

like below shown

select * from person where username LIKE "BAGANAN'S"

BUT THE SINGLE QUOTE IN BAGANAN'S THE QUERY GIVES ME PROBLEM

REGARDS
AMIR
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32628
    
215

Amir,
If you are using JDBC, you could use a prepared statement. If you are using raw SQL directly to Oracle, you need to use an escape character. This tells Oracle to use a special character (backslashes are common) to give the single quote special meaning.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
 
 
subject: like keyword in sql
 
It's not a secret anymore!