Results 1 to 4 of 4

Thread: Query to get common records

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Answers
    1

    Query to get common records

    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


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Query to get common records

    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;


  3. #3
    Junior Member
    Join Date
    Jul 2007
    Answers
    1

    Wink Re: Query to get common records

    Quote Originally Posted by debasisdas View Post
    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;
    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)


  4. #4

    Re: Query to get common records

    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)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact