• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Copying information from one MySQL DB Table to another, PHPMyAdmin


Somewhat eXPerienced
Hey guys,

I'll tell y'all what I have, what I'm doing, and what the problem is so you can understand it better.

Previously I've taught myself a bit of PHP and created mysefl a form with PHP that I could add calls into a database and call them back. I had created 12 seperate pages, 1 for each month for fire calls [it's for my fire department], and 12 seperate tables, one per month. I have recently been told that is bad programming and what I can do to fix it.

So now, I've added another field to the tables I've been working on that would allow me to show all information for a specific month, and sort by the run number, which is the primary key and an auto-incrementing digit.

The problem I'm running into is this: I created the table "2005" with the same fields as the other tables. I've been trying to copy the information out of one table and into 2005, starting with June since that's the first table that has information in it. I've been using the Operations tab under the table I want to copy as the source. There is a conflict though. When I start copying the other months, sometimes the primary key conflicts with another that was previously copied.

Since they were seperate tables, you might find run #2 in June, and run #2 in July. Is there a way that I could use a SQL Script, to copy the information out of the table, and without damaging the existing table [incase anything goes wrong] drop the primary key in the existing table, copy it over to 2005, and then reapply the keys in numerical order? Basically getting assigned a new primary key in the copy process?

Hope you guys understand what I'm talking about, I think that's the easiest way I can explain it. Please let me know if you have any questions, and thanks in advance!


Somewhat eXPerienced
Geffy said:
look at the Operations tab for the table in phpMyAdmin, or also take a look a the Export one as well
In my post I had stated that's what I had been using, it has an option to copy table with structure, data, or both to another table. I was copying data only. As I had stated though, the problem is that my primary key in each table sometimes conflicts with the primary key in another table, which messes up the copying entirely.

I need a way that it sort of starts copying it, and then it dismisses the primary key in what's being copied, then applies it to the new table and then reassigns the primary key... in that order. Otherwise, if I get rid of the primary key in the first step, that's going to give me problems with my already existing table.


I'm sorry Hal...
Political User
create a new empty table with the same structure
then populate it with the other 2 tables
insert into temp (field names (not PK)) select field names (not PK) from table 1
insert into temp (field names (not PK)) select field names (not PK) from table 2

then rename temp
than should do it.

At least i think thats what you want
Last edited:


Penguin Rancher
If your Run number is the only thing used as your primary key in the new table, and that is where your conflict lies, change the primary key on the new table to include the month or some other unique combination.

Primary Key (month,run)

instead of

run datatype primary key;

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member