Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking tables in 2 ways, Like ELSE condition

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

i have a "small" problem within Crystal reports - i try to link 2 tables, the problem is i need something like an else statement - here the things i try to do:

link table 1 and table 2 via ID1

in the case there is no matching in the two tables, do to the reason, that the value in table 2 is "0", it should check ID2 within table 2, but stays with ID 1 in table 1

is there any possibility to do this

any help is welcome

thanks & regards

rainer
 
I'm just learning about this myself. I think this will get you pointed in the right direction:

Add a new table - add table2 again. It will ask you to give the new table a different name like table2_b

Then in the visual linking expert, link
table1.ID1 *= table2.ID1 and
table1.ID1 *= table2_b.ID2

make sure you do left joins.

And then you'll have to edit the selection formula...

 
Hi nnaacc,

i tried this, but unfortunately it doesn't work - i get several records doubled.

and an other problem there is, that the grouping is by a third table which is right of table 2

Rainer
 
I'm not sure whether Sybase supports this in ODBC, but it is worth a try.
In Database|Show SQL Query, modify the FROM statement, so that instead of something like
FROM Table1
INNER JOIN Table2 ON Table1.ID = Table2.ID
INNER JOIN Table3 ON Table2.Blah = Table3.Blah
try
FROM Table1
INNER JOIN Table2 ON Table1.ID = CASE WHEN Table2.ID <> 0 THEN Table2.ID ELSE Table2.ID2 END
INNER JOIN Table3 ON Table2.Blah = Table3.Blah
I'm not sure whether you need inner joins or outer joins, as you don't indicate any reason to choose one over the other. Malcolm Wynden
I'm for sale at malcolm@wynden.net
 
HI Malcolm,

i'm not able to chose this point in the database-menu.

Rainer
 
Are you going directly against Sybase/ODBC, or are you using a *.qry file created with the Crystal SQL Designer? Malcolm Wynden
I'm for sale at malcolm@wynden.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top