Select all data from one table and insert them into another table

advertisements

I wanted to select all the data from one of my table and insert it to another table. I have this code but it wasn't working..This is what the phpMyadmin says "MySQL returned an empty result set (i.e. zero rows). (Query took 0.0010 seconds.)"

Here is my code:

if(isset($_POST['select_table']))
{
    $select_table = mysql_real_escape_string($_POST['select_table']);
    $query_select = "INSERT INTO pdf_table
                    SELECT * FROM $select_table";
    $select_query = mysql_query($query_select,$connectDatabase);
}


Please ensure that both the tables have equal number of columns. It is a good practice to use following way for inserting records with select query :-

INSERT INTO pdf_table (column_1, column_2) SELECT column_1, column_2 FROM $select_table