usage of LIKE, compare 2 fields.
Posted by: Ahmad Sakhi
Date: November 13, 2016 07:52PM

Hello All,

Considering the following 2 tables:

TABLE_1
ID    URI_EXT
12    IMO0001_0001_59909
13    IMO0002_0002_60109
14    IMJ00001_00059_000292
...


TABLE_2
ID    URI
01    IMO0001
02    IMO0002
03    IMJ00001
...

I need to join these 2 tables using the URI and URI_EXT field. But, as we can see in the first table the URI_EXT has extra information. I need to use a query something like the following,

SELECT 
    a.id, 
    a.uri_ext, 
    b.id, 
    b.uri 
FROM 
    table_1 a, 
    table_2 b 
WHERE 
    a.uri_ext like b.uri AND
    b.uri='IMJ00001';

Is there a way, I can use the SUBSTRING() function to parse the uri_ext field where the first occurance of _ (underscore) is and do a compare of the two field? i.e.

WHERE SUBSTRING(a.uri_ext, 0, '-') = b.uri

Or there maybe another way?

Options: ReplyQuote


Subject
Written By
Posted
usage of LIKE, compare 2 fields.
November 13, 2016 07:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.