Reference 2007 - Project Management Software - High Paying Adsense List - Find services - Communications Technology Articles

PDA

View Full Version : Copying field from one column into another


Baz@rr
May 4th 2006, 3:00 pm
Hi all, looking for some advice. I'm a complete database mong, so apologies if it's ludicrously simple or that.

What I'm trying to do is copy across data from a table called uk_info to another table called idx_list.

The field I want to copy from uk_info is called 'Postcode'. I want it to go into a field called 'postcode' in idx_list.

This was what I tried first:

INSERT INTO 'idx_list' ('postcode')
SELECT 'Postcode' FROM 'uk_info'

Which copied across the info okay. But...

I wanted the postcode data to go into the idx_list table starting at record 1. Instead it added new records after all the existing ones. I have a list of business names in both tables, and want to add the postcode data from one table to the other. Both tables are currently ordered the same way by a numerical ID.

So instead of now having business names plus corresponding postcode in idx_list, I have the business name records with a NULL postcode field, and then the postcode records with a NULL business name field. Not what I'm after at all.

Apologies if this doesn't make much sense. I can clarify anything that's not already clear. Any help much appreciated.

Baz

exam
May 4th 2006, 3:12 pm
UPDATE idx_list SET idx_list.postcode=uk_info.postcode WHERE idx_list.id=uk_info.id

That would probably work as long both tables have the same ids.