By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,850 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,850 IT Pros & Developers. It's quick & easy.

Newbie question : SQL search problem with substituted characters

P: 1
Hi All,

I have set of strings in the db2 table and two range keys to search. I have to finds strings the table which would be in between the range of keys defined.

Strings in the colum to search (COLUMN_TO_SEARCH) :

Range of keys defined : KAVIC$$$ , KAVIC$$/

SQL query may looks like :

select <COLUMN_TO_SEARCH> from <table> where COLUMN_TO_SEARCH <= 'KAVIC$$$' and COLUMN_TO_SEARCH >='KAVIC$$/'

The above query will not return any result sets, So how we can do proper query that returns correct result set ?


If we do substring based SQL, then it returns correct result set, But i can't do that search always. So that solution may be invalid.

substring based query :

select <COLUMN_TO_SEARCH> from <table> where substr(COLUMN_TO_SEARCH,1,5) <= substr('KAVIC$$$',1,5) and substr(COLUMN_TO_SEARCH,1,5) >= substr('KAVIC$$/',1,5);
Nov 12 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.