So I have a table ‘A’ with has column of numerical values of 12 digits, now there is another table ‘B’ which has only first 6 digits of the same numerical value, I want to join both the tables using the first 6 digits of table ‘A’ and already 6 digits of values in table ‘B’.
SELECT *
FROM A
inner join B ON A.K1 = B.K1
here K1
is basically the first 6 digits of the number which I created as a new column in output.
I cannot use ALTER
as it is a live table.
2
Answers
That’s what I can think of having as much information as you provided. I do not know whether your business requires that it should be an inner join, left/right outer join or full outer join.
Union is a completely different concept: that just reunites into a data set similar columns from different data sets. And there is the simple UNION which makes Oracle to sort and eliminate duplicates and UNION ALL, which takes all the data, including duplicates if any.
You could just join on the first 6 digits then:
Example data:
Table
test1
:Table
test2
:The statement
will produce
Test it in this db<>fiddle.