tags:

views:

28

answers:

1

I have tables, 1 called "articles" and another called "links".

I want to take the url and title from the table links and update the articles table with the data from the links table. I am unsure how to do this. The links table has article_id referenced to it, can anyone help?

Here is some pseudo-code if this helps?

UPDATE articles 
   SET articles.url, 
       articles.title = (SELECT links.url, 
                                links.title 
                           FROM links 
                          WHERE articles.id = links.article_id)

Does this make sense?

+3  A: 
UPDATE articles, links
SET articles.url = links.url,  
articles.title = links.title
WHERE articles.id = links.article_id

OR

UPDATE articles
INNER JOIN links ON (articles.id = links.article_id)
SET articles.url = links.url,  
articles.title = links.title
a1ex07
Wrikken
-1 for the kind of join used - this join technique leads to a lot of headaches. provide advice with Explicit Joins please.
Raj More
Updated to include both choices...
a1ex07
-1 removed, +1 put in place.
Raj More
Wrikken
@Wrikken: No worries, preaching to the choir about ANSI-92 :)
OMG Ponies
Thanks guys, worked woooonderfully
JeffTaggary