Join two mysql tables

后端 未结 3 1023
小鲜肉
小鲜肉 2021-01-28 15:11

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: I

相关标签:
3条回答
  • 2021-01-28 15:51

    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

    0 讨论(0)
  • 2021-01-28 16:01
    SELECT * FROM articletable RIGHT OUTER JOIN metatable ON articletable.id=metatable.article_id
    
    0 讨论(0)
  • 2021-01-28 16:07

    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.

    0 讨论(0)
提交回复
热议问题