cancel
Showing results for 
Search instead for 
Did you mean: 

LEFT outer join - pains

04-20-2021 10:36 PM
1250 views 8 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hello,

Can some one tell me how to do a left outer join in Crystal for two (2) different scenarios:

(1.) Two tables and two fields in both tables

(2.) Three tables one field from table A, one field from table B, and two fields from table C. The Left is table A and B.

I knowhow to do a Left outer join with two tables and one field.

The reason for the Left outer join is, I want the Left portion of data to be present even if there is not a match.

Thanks,

Paul

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor

You would Left Outer from A to C and Right Outer from C to B so that the links are "chained". Unfortunately, since there is no way to link from A to B, if there is no data in C, you'll only get data from A and B will be blank.

The query you show would look like this:

Select * from A
Left join C as u
ON A.first_name = u.first_name 
  and A.Las_name = u.Last_ name

You don't need to use "Select * from..." for the table you're joining to - just join directly to the table.

-Dell

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Likes

You can't join from one field to two fields - it won't work. What do the two different fields represent?

-Dell

former_member731159
Participant
0 Likes

Sorry about that, I wasn’t very clear.

If I have table A with a field called Name,

Table B with a field named SSN

And Table C with two fields - one named Name

And SSN. How can I do a join that allows A and B to join to C.

Can I just to a Left outer from A to C

And a Left outer from B to C.


also, how can I do an left outer join with two tables and two fields. Example:

Select * from A

Left out join (select * from C) u

ON ( t.first_name = u.first_name and

t.Las_name = u.Last_ name)

former_member731159
Participant
0 Likes

How would I do this in Crystal.

I know how to do it with native SQL, but how would I graphically do this so that crystal would use two fields to perform a Left outer join.

Currently, when I link two tables in Crystal, I can only do a Left Outer Join with one field.

Thanks...

DellSC
Active Contributor
0 Likes

As I said in my previous answer, link A >> C >> B. This means delete the link you have from B to C and then redraw it starting at C and drawing to B. Then make the link from C to B a Right Outer join instead of Left Outer.

-Dell

former_member731159
Participant
0 Likes

Sounds good.

Thank you very much...

former_member731159
Participant
0 Likes

Dell,

You answered my big question without even knowing it. I wasn't aware that all you had to do is add another link when performing a join for two fields . Example: ON (t.field1 = u.field1 AND t.field2 = u.field2). I looked back over your answers and it became clear that I could do this.

Thaaaaaaaaaaaaaaaaaaaaank you, for your help...