Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: And-Or-Where-clause Post Reply Post New Topic
Author Message
Hardie82
Newbie
Newbie


Joined: 05 Apr 2010
Online Status: Offline
Posts: 2
Quote Hardie82 Replybullet Topic: And-Or-Where-clause
    Posted: 05 Apr 2010 at 10:06pm
Hi all,

I am new at crystal and I got the task to create a report includes two tables. But I have a problem to link these two tables correctly. I need a sql-statement like this:

SELECT field1, field2, ... FROM table1, table2 WHERE (table1.field1=table2.field1 OR table1.field1=table2.field2) AND table1.field3=0

With the database-assistent I can link the fields but get only AND-bindings in the final sql-statement of crystal. Is there any possibility to get the required sql-statement?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 06 Apr 2010 at 7:00am
Yes, you are right that the database assistant will always use the AND clause in your WHERE clause. Since you want to use the OR clause, you can create a custom Command where you can enter your own SQL statement. In the database expert, open the connection you want to use and double-click the Add Command option. THen copy and paste the SQL statement into it (making sure to change the AND to an OR). Save it and use it as the datasource for your report.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Hardie82
Newbie
Newbie


Joined: 05 Apr 2010
Online Status: Offline
Posts: 2
Quote Hardie82 Replybullet Posted: 06 Apr 2010 at 10:37am
Thanks for your answer. That works fine for using it with the report-generator. But if I want to use this report with the crystal-server as an automatic action, I got the message that a table couldn't be found. My report includes only the custom command.

We use an older version of the crystal-server (think it was 6), but a newer version of the generator (10). Could this be a compatibility problem?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 06 Apr 2010 at 3:07pm
Unfortunately, I can't answer why CR Server is not accepting the new SQL.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
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.000 seconds.