File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to write select query when where condition contains ampersand symbol(&)?

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to write a select query when where condition contains ampersand(&) symbol?

example:

select * from subjects where name='abc & xyz';
 
George Stoianov
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the RDBM's character escape sequence, or you might consider using a prepared statement with the respective driver and this should be taken care of auto-magically.
 
Leandro Dantas
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

The best approach is use the PreparedStatment as George Stoianov pointed out.

using the setString method will let the driver use the correct method to escape the symbol.

Regards.
 
Paul Campbell
Ranch Hand
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Abhishek Reddy Chepyala:
how to write a select query when where condition contains ampersand(&) symbol?

example:

select * from subjects where name='abc & xyz';


select * from subjects where name='abc &'||'xyz'
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic