Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Table Linking Post Reply Post New Topic
Author Message
huff
Newbie
Newbie


Joined: 10 Apr 2015
Online Status: Offline
Posts: 4
Quote huff Replybullet Topic: Table Linking
     Posted: 18 Jun 2015 at 10:02am
I've created a report that uses Main File, Address File, and Address File. I want all records from the Main File and only those records from the first Address File where addresstype='R' and contacttype="", and only those records from the second address file where addresstype="M" and contacttype="".

I am joining the Main File to the Address files with a left outer join, but I am not getting all of my Main File records.

I have tried adding in criteria that says ((addresstype='R' and contacttype="") and addresstype='M' and contacttype="")) or isnull(empid). Empid is the field I am linking on, but it doesn't seem to change the results.

Thanks for your help.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 18 Jun 2015 at 11:26am
Your select critieria is applied after the join takes place.
Trying to fix that only in crystal can get a a bit tricky.
You can handle this by creating a command or a stored procedure much more simply. Or you can create a view and use it ior you can
 
 
Are you linking the AddressFile to the MainFile twice? You shouldn't need to.
YOu can use a subquery on AddressFile and left join to it or you can either apply your criteria to the join 
 
//Join example
select * fom MainFile mf
Left Join AddressFile af ON mf.Empid = mf.Empid and
((af.addresstype='R' and mf.contacttype="") OR (mf.addresstype='M' and mf.contacttype=""))
IP IP Logged
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