cancel
Showing results for 
Search instead for 
Did you mean: 

Join on Substring

Former Member
0 Kudos

Hi All,

I have two tables I would like to join. Table 1's PK is a number, Table 2's PK is identical to Table 1, but with a character at the front:

Table 1 PKTable 2 PK
123J123
124X124
125J125
126K126
127X127

How can you join on a substring in Information Steward's view screen?

Thanks,

Katherine

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Katherine,

You can use substr function to retrieve a specific portion of string in your join. Here is the function usage and examples

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks guys! Worked like a charm.

former_member186897
Contributor
0 Kudos

Katherine Leenhouts,


This is simple. You can directly do this in where clause. Considering your field name in both tables are ID.

Table_1.ID=cast( substr(Table_2.ID,2,length(Table_2.ID )),'INT')

  • substr : it will read string from 2nd character till end.
  • Cast is being used to suppress the warding message in case first table field ID is in int. You can remove casting in case your both tables have varchar for these fields.

Hope this helps.


Regards,

Ansari MS