Hi Gwenael,
are there trailing blanks in PK1 or PK2, are they defined as CHAR or VARCHAR?
The LIKE might also return wrong rows, when PK1 is not fixed length, e.g. 'abcd-1' LIKE 'abc' || '%'.
To extract the first part up to the suffix you might use SUBSTRING:
substring(p1 from 1 for position('-' in P1)-1)
If the '-' might be missing you have to put it into a CASE.
In TD14 there are built-in functions to split strings, e.g. STRTOK, but all those solutions will not fix the root cause of your problem: bad database design.
The suffix should be in a seperate column, so both tables can share the same PI, otherwise you'll never get fast joins.
Dieter
Hi Gwenael,
are there trailing blanks in PK1 or PK2, are they defined as CHAR or VARCHAR?
The LIKE might also return wrong rows, when PK1 is not fixed length, e.g. 'abcd-1' LIKE 'abc' || '%'.
To extract the first part up to the suffix you might use SUBSTRING:
If the '-' might be missing you have to put it into a CASE.
In TD14 there are built-in functions to split strings, e.g. STRTOK, but all those solutions will not fix the root cause of your problem: bad database design.
The suffix should be in a seperate column, so both tables can share the same PI, otherwise you'll never get fast joins.
Dieter