Php 从3个表中查询数据

Php 从3个表中查询数据,php,mysql,Php,Mysql,我这里有三张桌子: + _news : id, title, url, image // This table contents all data of news. + _block : bid, id // This table content id of news and bid + _block_cate : bid, title, url // This table content type of news : PHP, SQL, HTML 每个表的数据如下所示: + _news

我这里有三张桌子:

+ _news : id, title, url, image // This table contents all data of news.

+ _block : bid, id // This table content id of news and bid

+ _block_cate : bid, title, url // This table content type of news : PHP, SQL, HTML
每个表的数据如下所示:

+ _news : id, title, url, image
          1   title1 url1 image1
          2   title2 url2 image2

+ _block : bid, id // id here is if of news.
            1   1
            2   1
            1   3

+ _block_cate : bid, title, url // This table contents data of each type.
                 1   PHP    php
                 2   SQL    SQL
                 3   HTML   html
我试图在我的主页上打印这样的结果:

+ _news : id, title, url, image
          1   title1 url1 image1
          2   title2 url2 image2

+ _block : bid, id // id here is if of news.
            1   1
            2   1
            1   3

+ _block_cate : bid, title, url // This table contents data of each type.
                 1   PHP    php
                 2   SQL    SQL
                 3   HTML   html
  • 新闻(1)-标题
  • 类型:PHP、SQL

  • 新闻(2)-标题2

  • 类型:HTML
我尝试了两级查询,但不起作用。 你知道这个问题吗

//你也可以在这里查看演示 我正在尝试制作一个这样的网页。每个漫画都会显示自己的漫画信息以及它所属的类型。
我希望有人能给我一个建议。

从你的问题中我不清楚你需要什么。我想你需要这样的建议

select NW.title,* from _news NW
left join _block BK ON NW.id=BK.id
left join _block_cate BC ON BK.bid = BC.bid
这应该对你有用