Skip to main content
Question

Joining tables

  • November 7, 2025
  • 5 replies
  • 66 views

Forum|alt.badge.img+9
  • Sidekick (Customer)

Hello, how can I connect two tables through part_no? Table1 and table2 have common column part_no, but for example table1 has part_no = A-11-2233_56_FRAME and table2 has part_no = 2233_56_FR. I want connect it only to those which have common data. Maybe some REGEX but I am not sure how. 

5 replies

Furkan Zengin
Ultimate Hero (Partner)
Forum|alt.badge.img+21
  • Ultimate Hero (Partner)
  • November 7, 2025

Hi ​@Ed22 

How about this one?

SELECT *
FROM table1 t1
JOIN table2 t2
ON t1.part_no LIKE '%' || t2.part_no || '%';

or this one?

SELECT *
FROM table1 t1
JOIN table2 t2
ON REGEXP_LIKE(t1.part_no, t2.part_no);

Please try if it fits your requirement.

Hope this helps

Furkan


Forum|alt.badge.img+9
  • Author
  • Sidekick (Customer)
  • November 7, 2025

SELECT *

FROM table1 t1

JOIN table2 t2

ON REGEXP_LIKE(t1.part_no, t2.part_no) this isnt working. t1.part_no = M004787_7000_FRAME_FINAL AND t2.part_no = A-33-M004787_7000_FRAME_FI this wont find


Forum|alt.badge.img+14
  • Superhero (Partner)
  • November 7, 2025

@Ed22 I’ve had some luck using INSTR.  Although, fair warning, it may be slow and may return some unexpected results if T2 has short part numbers that are contained in the T2 part number. (Like “A”).


Michael Kaiser
Sidekick (Customer)
Forum|alt.badge.img+9
  • Sidekick (Customer)
  • November 19, 2025

Hi,
t1.part_no = A-11-2233_56_FRAME

t2.part_no =          2233_56_FR

what about using (dynamic) substring?

2233_56_FR => 10  from the right side 13 “away”.

 

SELECT *

FROM table1 t1

JOIN table2 t2

ON

sustring(t1.part_no, -13, 10) = t2.part_no

HTH
Michael

 

Found on: https://stackoverflow.com/questions/3440849/get-string-from-right-hand-side
sql
substr(STRING, ( length(STRING) - (TOTAL_GET_LENGTH - 1) ),TOTAL_GET_LENGTH)


Forum|alt.badge.img+6
  • Sidekick (Customer)
  • November 19, 2025

@Ed22 , the following should do it

SELECT    1
FROM dual
WHERE
regexp_substr('A-11-2233_56_FRAME', '\d{4}_\d{2}') = regexp_substr('2233_56_FR', '\d{4}_\d{2}');