คืนว่าจะดึงข้อมูลอีกตารางมาแสดงร่วมกับข้อมูลเดิมอ่ะครับทำยังไงครับ
Code (PHP)
$sql="SELECT * FROM Tb_product;";
$query=mysql_query($sql) or die(mysql_error());
while($items=mysql_fetch_array($query)){
$sql_detail="SELECT * FROM tb_order_detail WHERE ref_id_prd='$items[id_prd]';";
$query_detail=mysql_query($sql_detail);
$detail=mysql_fetch_array($query_detail);
echo $items[id_prd];
echo $items[name_prd];
echo $detail[number];
echo $detail[price];
}
Date :
2010-12-22 10:16:07
By :
aunjijoke
ใช้การ JOIN TABLE
Date :
2010-12-22 13:54:08
By :
iieszz
SELECT number.id_prd,number.name_prd,tb_order_detail.number,(tb_order_detail.number * tb_order_detail.price) as sum
FROM Tb_product,tb_order_detail
WHERE Tb_product.id_prd = tb_order_detail.ref_id_prd
ประวัติการแก้ไข 2010-12-22 16:24:16
Date :
2010-12-22 16:23:59
By :
extenser
Code (PHP)
select tb_product .name_prd, tb_order_detail.ref_id_prd, tb_order_detail.number, tb_order_detail.price
from tb_product, tb_order_detail
where tb_product.id_prd = tb_order_detail.ref_id_prd
Date :
2010-12-24 10:01:47
By :
cmdping
Load balance : Server 00