Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: LIKE Operator using Special Characters Post Reply Post New Topic
Author Message
Dr4ke
Senior Member
Senior Member


Joined: 09 May 2014
Online Status: Offline
Posts: 209
Quote Dr4ke Replybullet Topic: LIKE Operator using Special Characters
    Posted: 03 Nov 2014 at 3:49am
Afternoon,

I currently have two different types of data in my report:

1) {Letter}:\ (E.g. C:\)

2) {Letter}: (E.g. C:)

I want to exclude the first option using "??\" but it throws up a SQL Syntax error.

I've been able to find a workaround for this scenario, using ?:?, but wondered if there was any reason you can't use \ in a LIKE formula?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Nov 2014 at 5:44am

Testing this out I did not get any errors.

What exactly is the formula you are using and where are you placing it?
IP IP Logged
Dr4ke
Senior Member
Senior Member


Joined: 09 May 2014
Online Status: Offline
Posts: 209
Quote Dr4ke Replybullet Posted: 03 Nov 2014 at 6:07am
Hi DBlank,

That's strange! The formula used is

not ({TableName.FieldName} like "??\")


Which then displays two errors. The first one is:

"Failed to retrieve data from the database." and gives the option to click 'Ok'.

Once clicked the following error appears

"Failed to retrieve data from the database. Details: 4200. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "_\')' at line 1."

this only happens when a '\' is at the end of a LIKE clause..
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Nov 2014 at 6:51am
are you using this as your select statement?
IP IP Logged
Dr4ke
Senior Member
Senior Member


Joined: 09 May 2014
Online Status: Offline
Posts: 209
Quote Dr4ke Replybullet Posted: 03 Nov 2014 at 8:39am
No this is in the select expert
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 Nov 2014 at 12:13pm
I suspect that the translation from Crystal to MySQL syntax is not working correctly (I have seen similar issue before).  You may need to create a stored procedure or command with the 'properly' formatted WHERE clause.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Nov 2014 at 1:46pm
can it be moved to a crystal formula and then use that result in the select?
IP IP Logged
Dr4ke
Senior Member
Senior Member


Joined: 09 May 2014
Online Status: Offline
Posts: 209
Quote Dr4ke Replybullet Posted: 03 Nov 2014 at 9:59pm
Thanks guys.

DBlank - what do you mean regarding the formula? Something like the below?

IF {field} LIKE ??/ Then "Exclude" Else "Include"
and then use the Select Expert on Exclude?
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 03 Nov 2014 at 10:06pm
can you use right({field},1)="\"
IP IP Logged
Dr4ke
Senior Member
Senior Member


Joined: 09 May 2014
Online Status: Offline
Posts: 209
Quote Dr4ke Replybullet Posted: 03 Nov 2014 at 10:37pm
That works :-) allowing me to filter on 'True' or 'False'.

Very strange why it wouldn't work in the first place.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.