Skip to Content
Nov 17, 2010 at 04:36 PM

Left Outer Join with more than two tables in both CR 8.5 and XIR2


I am trying to create a report and I have tried two versions of Crystal but I ultimately need the report in CR8.5 for compatibility with the client's system. I think I am starting to figure out what might be wrong and it might be my understanding of SQL, but I can't see why someone hasn't needed this in the past. Ultimately I want to see all projects and any journal entry that might be posted for that project.

Database is MySQL 5.0.38 and using MySQL ODBC driver 3.51.19.

Project header table information will be populated. Each line item on a journal entry can be tagged with the project ID. But for me to pull the journal entry date I need also to link to a third table for the journal entry header info.

I want to see all projects, whether a journal entry has been posted or not.

So the links are like this

ProjectHeader --->Left Outer Join ---> JELines ---> Inner Join ---> JEHeader

I think in this scenerio Crystal is treating the LOJ as an IJ.

I created two brand new reports today, one in CR8.5 and one in CR XIR2. Once I edited the automatic CR8.5 SQL statement (which I have been doing for years, usually without problem), they both ran properly. I linked customers to their invoices. Customers without invoices showed properly. But then I linked the invoices to the payments of the invoices and immediately lost customers without orders in both reports.

So apparently only two tables are allowed in Outer Joins. Does this make sense? I checked out the w3schools tutorial on SQL and it doesn't mention this limitation and I can't find anywhere else that it specifically indicates this but all samples of code I have seen only show two tables. I just thought for presentation as a sample that was easiest to understand and we could expand as necessary.

If this is correct, how does one go about accounting for this kind of thing? One solution that goes through my mind is creating a view at the database level for the link between journal entry lines and journal entry headers. Would this be a good solution under normal circumstances?

A second option that I had to implement because of timelines, is to use a subreport linked to the main report through the project ID to pull the information for the journal entries and just pass the totals I need to the main report through a shared variable.

These aren't normal circumstances because I don't have access to the database so I can't create the view. I have come across this concept several times and I have been able to use subreports to solve it but I am trying to find a better solution for the future as sometimes subreports can be slow. So are there any alternatives I have not considered here?

TIA rasinc