PHP HelpPHP Help

Online Community that helps beginners learn PHP,
and webmasters solve PHP coding problems

since 1999





Using SQL to Copy Table Content

How to copy the contents of one table to another using SQL is not immediately obvious.

Create and Populate Table

create table mytablecopy select * from originaltable
 

Copying a Table into an Existing Table

insert into originaltable select * from mytablecopy
 

Sub-Selects

MySQL does support sub-selects. For example you can do this:

select * from things where thing.userid not in (select userid from otherthings)
 
Discuss on Forum   |   More Tutorials »




Copyright © 2017 PHPHelp.com