LEFT String Query in Crystal
Hello friends,
I'm sure this has been asked before, but I can't make this query work for me as I am new to crystal.
I'm using Crystal Reports 10.
I need to search an Account Code string and find "35" at the 5th and 6th positions in the string.
The account code looks like this: PRCP353F5720-06101
The number "35" will ALWAYS be at the 5th and 6th position in this field.
I know the below is not correct, but I need to query something like:
Select *
From table
Where Account_Code Left("35",5)
I also need to run the above in SQL to test my results. I can't make this work in SQL and can't seem to get a formula to work in Crystal in record selection.
Can somebody please help me with the correct syntax for both of those?
Re: LEFT String Query in Crystal
Assuming SQL Server
You can't use Left unless you are searching from the beginning of the string.
ie Select * From table Where Left(Account_Code, 6) = 'PRCP35'
Use SubString instead
Select * From table Where Substring(Account_Code, 5, 2) = '35'
In Crystal and Access use Mid
Mid ({Table.Account_Code}, 5 , 2 ) = "35"
Re: LEFT String Query in Crystal
This worked great! Thank you!!!
:wave: