Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.