Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



SQL Query For Copy records from one table to another

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 16-01-2009
Member
 
Join Date: Dec 2008
Posts: 9
SQL Query For Copy records from one table to another
  

Hi,
I need some help,
Can anyone tell how to copy records from one table to another table by using SQL Query.

Reply With Quote
  #2  
Old 16-01-2009
Member
 
Join Date: Apr 2008
Posts: 1,944
Re: SQL Query For Copy records from one table to another

If you want to create a single, new table with all the records (rather than overwriting one of the existing tables):

SELECT * FROM Table1OfPC1 ;
UNION ;
SELECT * FROM Table1OfPC2 ;
UNION ;
SELECT * FROM Table1OfPC3 ;
INTO TABLE NewTable1
Reply With Quote
  #3  
Old 16-01-2009
Member
 
Join Date: May 2008
Posts: 2,001
Copy Unique Records from one Table to Another Table

You can use the following query.

Code:
insert into newtablename select * from oldtablename

But if you want to Copy only Unique Records from one Table to Another Table
then use this query.

Code:
insert into newtablename select distinct * from oldtablename
Reply With Quote
  #4  
Old 16-01-2009
Member
 
Join Date: Dec 2008
Posts: 7
Re: SQL Query For Copy records from one table to another

Hi,

Very nice piece of code.
Short and simple to understand.
Thanks for sharing your knowledge with us.

Keep posting.
Reply With Quote
  #5  
Old 23-05-2010
Member
 
Join Date: May 2010
Posts: 1
Re: Copy Unique Records from one Table to Another Table

Quote:
Originally Posted by Katty View Post
You can use the following query.

Code:
insert into newtablename select * from oldtablename

But if you want to Copy only Unique Records from one Table to Another Table
then use this query.

Code:
insert into newtablename select distinct * from oldtablename


This is very simple & good idea to copy records from 1 table to another which is already existing Thank You.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SQL Query For Copy records from one table to another"
Thread Thread Starter Forum Replies Last Post
PHP mysql select unique records from one table Captain Carrot Software Development 6 13-05-2010 12:18 PM
Select unique records from a table Conraad Software Development 5 13-05-2010 12:01 AM
Query to find out duplicate records Shophia_D Software Development 5 22-12-2009 10:03 AM
Unable to delete records from Two Joined table Broot Software Development 3 22-09-2009 03:44 PM
How to specify the table containing the records you want to delete Fragman Software Development 3 08-08-2009 11:57 AM


All times are GMT +5.5. The time now is 06:03 PM.