Ads were blocked by your webbrowser.

This is not a problem, but keep in mind that developing HeidiSQL, user support and hosting takes time and money.

You may want to send a donation instead.

Adding a new Column from a separate Table...

Ash501's profile image Ash501 posted 7 years ago in General
Is there an easy way to merge data from one table to another?

Need to ADD a 'whole' Column from a one Table into different one. They both have a common ID. Is there an easy way to do it with HeidiSQL?

How about a 'part' of the Column only?

Thanks for your help!
ansgar's profile image ansgar posted 7 years ago
You need to create the column name/type first in the target table. Then you can
select col from table1 into table2

While that does not update anything, but inserts, of course.
ansgar's profile image ansgar posted 7 years ago
oh, it's too early in the morning. I meant:
insert into table2 (col) select col from table1


Ads were blocked by your webbrowser.

This is not a problem, but keep in mind that developing HeidiSQL, user support and hosting takes time and money.

You may want to send a donation instead.
Ash501's profile image Ash501 posted 7 years ago
This inserts into end of records. Need to update into current records.../or empty column...so that it would be alongside current records.

Is that what you mean by update? How is that done?
Sorry I'm new to SQL....

Thanks anse!
ansgar's profile image ansgar posted 7 years ago
In that case you will need an equal identifier column in both tables (let's call it "someuniquekey"):
UPDATE
table1 AS t1, table2 AS t2
SET t1.col=t2.col
WHERE t1.someuniquekey=t2.someuniquekey
Ash501's profile image Ash501 posted 7 years ago
Thanks anse!!! Just what I needed, a happy camper ={:-))
& you make it look so easy....

Please login to leave a reply, or register at first.