Migrating Data from One Table to Another Using SQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cfytable
Forum Commoner
Posts: 29
Joined: Thu May 12, 2005 3:36 pm

Migrating Data from One Table to Another Using SQL

Post by cfytable »

I have two tables. I want to migrate the data from Table B into Table A (below). There are no explicit links or key between the two tables, but TextID in Table A corresponds to ID in Table B.

Table A
ID (auto) e.g. 2002
Title e.g. My Article Title
TextID e.g. 38

Table B
ID (auto) e.g. 38
Keywords e.g. Blah, blah, blah
Body e.g. Article text

Can this be accomplished via SQL? Is it possible to insert selected data along the lines below? If so, can someday advise me on the proper syntax? Any help would be appreciated.

(This assumes that I've created the corresponding columns in Table A)

INSERT INTO TableA (Keywords, Body) VALUES (??????) WHERE TableA.TextID = TableB.ID
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Look at the syntax for INSERT ... SELECT
Post Reply