aspose file tools*
The moose likes JDBC and the fly likes how to write select query when where condition contains ampersand symbol(&)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to write select query when where condition contains ampersand symbol(&)?" Watch "how to write select query when where condition contains ampersand symbol(&)?" New topic
Author

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

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
how to write a select query when where condition contains ampersand(&) symbol?

example:

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


Abhishek
George Stoianov
Ranch Hand

Joined: Jan 15, 2006
Posts: 94
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

Joined: Feb 01, 2007
Posts: 14
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

Joined: Oct 06, 2007
Posts: 338
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
 
subject: how to write select query when where condition contains ampersand symbol(&)?