2

I am trying to join two oracle database tables where the columns to join on contain slightly different data.

For example Table A has a column 'ref' and Table B has a column 'id'.

A.ref contains data like A1234567890B and B.id contains data of the form 1234567890

I have tried joining the two based on the following query;

SELECT * FROM A INNER JOIN B
ON SUBSTR(A.ref, 2,10) = B.id;

But this has returned no results when I know that there is matching data from this substring.

Any ideas?

4

2 回答 2

0

我最终能够通过将 SUBSTR(A.ref, 2,10) 填充到 12 个字符来解决这个问题。

于 2013-10-14T17:54:59.587 回答
0

你可以尝试这样的事情:

SELECT * FROM A INNER JOIN B ON regexp_substr(A.ref, '^[[:alpha:]]+([[:digit:]]+)[[:alpha:]]+$',1,1,'c',1) = B.id

于 2013-09-30T14:18:57.020 回答