Jump to content

dump data from one table to another


abdfahim

Recommended Posts

Hi,

 

I have 2 tables t1 and t2. They have identical columns only except t1 has one extra column x1. What I want is to dump data from t2 to t1, and in the x1 column, put the person's name (get from SESSION).

 

So, I want the best optimized way to do something like

 

mysql_query("INSERT INTO `t1` '".$usename."' , SELECT * FROM `shareltp`"); //which obviously doesn't work

 

Plz help

Link to comment
https://forums.phpfreaks.com/topic/218648-dump-data-from-one-table-to-another/
Share on other sites

well, my problem is the extra column in t1 table (say col0). How to incorporate that?

Are you asking how you take 7 columns and insert them into a 6 column table?  You can't.

 

If you're asking how to ignore a specific column, read the previous reply more carefully.

 

-Dan

well, my problem is the extra column in t1 table (say col0). How to incorporate that?

Are you asking how you take 7 columns and insert them into a 6 column table?  You can't.

 

If you're asking how to ignore a specific column, read the previous reply more carefully.

 

-Dan

 

I haven't ask either of them .. I want to take 6 column from a table and insert them in a 7 column table whereas filling up the 7th column with a constant (don't say to use default coz that constant will vary with the user)

If you can't calculate the last column's value on the fly (like in my query) then just pull all the data into a scripting language and make one huge insert out of it.  You haven't said how many rows or how you're going to get this mystery column's value.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.