How to copy a sql table into another sql table

How to copy a sql table into another sql table

If you want to copy a SQL table into another table in the same SQL server database, it is possible by using the sql select statement.
The syntax of copying table from one to another is given below.

Select * into  from   

The Example of copying table from one to another is given below, here we copy employee table into employee1. Using this command you can copy a sql table into another sql table in same database. You just have need copy that code, past and change the name of tables.

Simple mysql copy table Query :

select * into  employee1 from employee;

Mysql copy table query with PHP Script :

<?php
$hostname = 'localhost';
$username = 'root';
$pass = '';
$conn = mysql_connect($hostname, $username, $pass) or die(mysql_error());
mysql_select_db('temp_db') or die(mysql_error());
mysql_query(“SELECT * into `employee` from `employee1`”);
?>

Leave a Reply

Related Posts: You may like

comma separated values in mysql query

SQL statement to retrieve names beginning with A

Php pdo prepared statements select insert update queries

php pdo queries statements select insert update delete

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.