Hi, Consider there are two tables, emp and dept with deptno being common between them. I want to write a query, where in I want to get the common records of both the tables, using joins, and then insert the output to a new table.
Thanks
Murthy
Printable View
Hi, Consider there are two tables, emp and dept with deptno being common between them. I want to write a query, where in I want to get the common records of both the tables, using joins, and then insert the output to a new table.
Thanks
Murthy
please try thr following
insert into newtable select e.f1,e.f2,e.f3,d.f1,d.f2,.... from emp e,dept d where e.deptno=d.deptno;
[QUOTE=debasisdas;17324]please try thr following
insert into newtable select e.f1,e.f2,e.f3,d.f1,d.f2,.... from emp e,dept d where e.deptno=d.deptno;[/QUOTE]
insert into newtable (select employee.f1,employe.f2,employee.f3,department.f1,department.f2
from employee inner join employee.dno on department.dno
where 1=1)
Hope the query below is fulfilled your requirement.
insert into output(select e.eno,e.ename,e.deptno from emp e,dept d where e.deptno=d.deptno)