I tried to combined tables which is fus_shift and root table into a new table which is final table but it outputs like " ERROR at line 2: ORA-01789: query block has incorrect number of result columns ". I tried also joining table as my alternative but it also outputs " ERROR at line 3: ORA-00918: column ambiguously defined ". Is there another way to do combining and joining two table with different number of columns and having the same column name respectively? Thanks again:-)
code error:
create table final as
select * from fus_shift
union
select * from root;
code error:
select record_num,test_num,t_date,t_time,system_type,category,comments,val
from fus_shiftrpt,root
where record_num=record_num;
my tables:
fus_shift Table
Record_Num test date time system
-----------------------------------------------------------
1 test15 08-11-12 13:20:01 sys23
2 test17 08-11-03 14:24:00 sys24
3 test13 08-11-13 17:25:04 sys45
4 test15 08-11-14 18:24:00 sys67
5 test16 08-11-15 19:24:06 sys45
root Table
Record_Num category comments validated by
---------------------------------------------------
1 dirt checked admin
2 prog checked admin
3 dirt checked pe
4 wires checked ee
5 prog repair admin
emphasized text
You certainly cannot apply "Union" to your tables. It can be applied only if both queries return same number (and of similar type) of columns.
You can join the two tables but would have to use "table alias" while joining since "record_num" field is common in both the tables. Here is the query that would work for you
select
table1.record_num,
table1.test_num,
table1.t_date,
table1.t_time,
table1.system_type,
table2.category,
table2.comments,
table2.val
from
fus_shift table1,root table2
where
table1.record_num = table2.record_num;
I would use the following method:
SELECT *
FROM fus_shift
INNER JOIN root ON root.record_num = fus_shift.record_num
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.