当前位置: 动力学知识库 > 问答 > 编程问答 >

php - How to get data from 2 tables?

问题描述:

This question already has an answer here:

  • Querying 2 Tables in a single query

    3 answers

网友答案:
SELECT * FROM posts, posts_category WHERE category = 'category' 
AND 
status = 'publish'
AND
posts_category.post_id = posts.id
ORDER BY date DESC LIMIT 10;
网友答案:
  $sql = "SELECT * FROM posts WHERE status = 'publish' AND pid IN (SELECT pid FROM pcategory WHERE ptype='category_name') ORDER BY date DESC LIMIT 10";
分享给朋友:
您可能感兴趣的文章:
随机阅读: