Jump to content
Sign in to follow this  
Henry Olive

SQL SubStr

Recommended Posts

I wish everyone a healthy day.
 

Interbase 2007,
 

SELECT ARD.CODE,ARD.DEBIT,ARD.CREDIT
FROM  ACCRECDETAIL ARD
JOIN   ACCRECEIPT AR ON AR.RNO=ARD.RNO
WHERE (ARD.CODE >= SUBSTR('180',1,3)) and (ARD.CODE <= SUBSTR('190',1,3))

Above SQL works but i can get  Codes between '180' and '189' NOT 190

If i change WHERE CLAUSE like below i can get all records Code between '180' and '190'

WHERE (ARD.CODE >= SUBSTR('180',1,3)) and

            (ARD.CODE <= SUBSTR('191',1,3)) /* I changed 190 to 191 */

What is wrong ?
Thank You

Share this post


Link to post
Guest

"1901" <= "190"? It is not.

"1801" >= "180"? Yes.

 

WHERE ARD.CODE >= '180' and (SUBSTR(ARD.CODE, 1, 3) <= '190'

 

Aside; SUBSTR('180', 1, 3), besides being useless, is not very readable.

 

HTH

 

 

Edited by Guest

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×