0

I have two databases - one for articles and the another for the articles' meta information (Like author, date, category and atc.). I have the following columns in meta table: ID, article id, meta type and meta value. I wonder how can I join these two tables to get both - article and meta information - with one mysql query. The article id isn't unique in meta table, that is why I can't figure out how to access specific meta type and according value for the article.

King Julien
  • 10,981
  • 24
  • 94
  • 132
  • The database schema of the two tables would help. – Vasilis Lourdas Sep 29 '10 at 17:33
  • Did any answer help you? Just click the check mark to mark it as an accepted solution or vote it up. And please check your other questions for possible solutions, too. Thanks! :) (And yes, this is copy-pasted so new users are aware of the voting system.) – Henrik P. Hessel Oct 01 '10 at 16:07

3 Answers3

0
SELECT * FROM articletable RIGHT OUTER JOIN metatable ON articletable.id=metatable.article_id
Mike
  • 2,862
  • 10
  • 42
  • 55
0

SELECT * FROM article_table RIGHT JOIN meta_table ON article_table.article_id = meta_table.article_id;

You get repeats from the article table, but it gets all the meta data in a single query. I believe otherwise you need to use multiple.

Kyle
  • 1,978
  • 1
  • 18
  • 30
0

If what these guys said works for you, then take it, but your wording makes me think that its set up as two different databases with these tables inside of them. If this is the case, then read on.

Assuming the two databases are on the same server and mysql install, this link should help. Ran into this awhile ago, but my databases were on different servers >.<

http://www.shawnhogan.com/2005/12/cross-database-join-with-mysql.html

Ascherer
  • 8,223
  • 3
  • 42
  • 60