Question

I'm trying to join a table with user information in it to an existing Crystal report. I would like to create join based on the first 7 characters in one field in my first table matching a unique ID in my second table.

I'm pretty sure the equivalent SQL would just be

JOIN db.table2 on left(db.table1.userid, 7) = db.table2.userid

But I'm not sure how to translate this to what goes on in Crystal's GUI (or if it is even possible to do in Crystal). I would do it in Command, but the existing report is already using fields from a whole bunch of different tables linked through Crystal's own way of doing things and it would take forever to remap them all if I convert it.

Was it helpful?

Solution

You won't be able to do a join like that from the Database Expert but you could put that logic into the Record Selection Formula with left({table1.userid},7) = {table2.userid}.

It should be noted, though, that this is pretty hacky and CR generally doesn't like when you add two conventionally unjoined tables to a report like that. Just a quick local test tells me that doing it this way does not actually translate into a well-formed WHERE-clause, but that CR enforces the "join" locally. In other words, your mileage may vary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top