Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Table link Post Reply Post New Topic
Author Message
dibblejon
Newbie
Newbie


Joined: 05 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 32
Quote dibblejon Replybullet Topic: Table link
     Posted: 03 Nov 2011 at 12:34am
Hi
 
Can somone please help me with a table linking issue I have?
 
The tables link on OrdID
 
In tbl1 OrdID can have multiple records for one order eg.
 
OrdID : 1234, 1234, 1234
 
But in tbl2 OrdID will only have one record eg.
 
OrdID : 1234, 1235, 1236 etc
 
I need to show all records from tbl1 so I see all lines on an order eg. 1234,1234 etc
 
What join type should I use?
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 03 Nov 2011 at 3:49am
Will every OrdId exist in both tables, or can there be an OrdId in table 2  that will not have a matching OrdId in table 1?
 
If there is always a match, it doesn't really matter what sort of join you use as all records will be returned.
 
If not and you want all Table 2 records even if there is no table 1 record for that OrdId, you will have to use
...table2 left outer join table1 on table2.OrdId = table1.Ord_id
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Nov 2011 at 3:51am
if table 1 has at least one matching row per unique ordid in table 2 then you can use an inner join.
if table 1 has any ordid that does not exist in table 2 you would need an left outer join (assuming table1 as the left table)
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