Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

like keyword in sql

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34671
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic