一个查询中的三个表?

时间:2013-11-28 21:41:22

标签: php mysql sql

=================
Table : tb_kategori
- id_kategori (primary key)
- name_kategori
=================
=================
Table : tb_product
- id_product (primary key)
- id_kategori (foreign key)
- name_product
=================
=================
Table : tb_images
- id_images (primary key)
- id_product (foreign key)
- file_images
=================

我想以html显示:

我从网址获取id_kategori: product.php?id_kategori = 1

<ul>
  <li>
    <img src="[file_images]">
    <div>
      <h1>[name_product]</h1>
    </div>
  </li>
</ul>

如何在一个查询中调用SQL ???

1 个答案:

答案 0 :(得分:0)

SELECT * 
FROM
     tb_kategori k,tb_product p,tb_images i
WHERE k.id_kategori = p.id_kategori
  AND p.id_product = i.id_product