Home » SQL & PL/SQL » SQL & PL/SQL » Sql Question
Sql Question [message #19848] Sat, 13 April 2002 06:44 Go to next message
Pradeep
Messages: 55
Registered: July 2000
Member
Hi all,

I have a table and i want to insert all the data of a second table into the first one, how can it be done ? Both the tables have the same structure. how that could be done using single sql-statement, somehow i am not able to do it.

If anybody knows then please tell me ..

Thanks,
Prads
Re: Sql Question [message #19849 is a reply to message #19848] Sat, 13 April 2002 08:16 Go to previous messageGo to next message
Arish Zishan
Messages: 3
Registered: April 2002
Junior Member
insert into emp2(empno,ename,deptno)
select empno,ename,deptno from emp;
Re: Sql Question [message #19858 is a reply to message #19848] Sat, 13 April 2002 18:08 Go to previous message
ADEOYE SOLARIN
Messages: 2
Registered: April 2002
Junior Member
Since the structure of the tables are the same and the tables are identical however you can use a single select statement like this.It's called a subselect method.At the sql prompt type;
INSERT INTO TABLE
SELECT*
FROM TABLE1
WHERE (CONDITION);

NOTE THAT THE FIRST TABLE UP IS YOUR NEW TABLE (TABLE TO BE CREATED)
TABLE1 IS YOUR EXISTING TABLE (TABLE TO BE COPIED FROM)
WHERE IS THE CONDITION YOU WANT TO SPECIFY TO THE ACTUAL RESULT.
I HOPE THIS WILL SOLVE YOUR PROBLEM.IF NOT GET BACK TO ME.
Previous Topic: count function and self join
Next Topic: Using max function (?)
Goto Forum:
  


Current Time: Thu May 23 07:50:53 CDT 2024