sql to copy from one table to another

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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

sql to copy from one table to another

Post by neophyte »

I'm trying to get two columns from one table (articles) to copy into two columns of a second table (article_assignment). I keep getting a mysql error indicating a syntax error near VALUES.

Does anybody know where I've gone astray?

Code: Select all

INSERT INTO article_assignment(article_id, category_id) SELECT article_id, article_category FROM articles VALUES (articles.article_id, articles.article_category)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

COOKED THE GOOSE

Post by neophyte »

Code: Select all

INSERT INTO article_assignment(article_assignment.article_id, article_assignment.category_id) SELECT articles.article_id, articles.article_category FROM articles WHERE articles.article_id>14
n00b says, "You don't need to insert Values" :oops:
Post Reply