在mysql中加入两个表并在表中显示答案

时间:2015-03-23 08:21:09

标签: php mysql join left-join

enter image description here

这是我的桌子。通过加入前2个表我需要在PHP中回答,如第三个表

我尝试了查询

            $sql="SELECT 
                ROUND(duct1.length * duct2.duct_63, 1) as d1, 
                ROUND(duct1.length * duct2.duct_125, 1) as d2,
                ROUND(duct1.length * duct2.duct_250, 1) as d3, 

                FROM duct1 JOIN duct2";

重复值。请帮帮我..

1 个答案:

答案 0 :(得分:1)

JOIN查询就像这样。

SELECT
   (field1, field2, field3)
FROM table1
JOIN fieldname
ON table1.field1 = table2.field1
WHERE fieldname = $fieldname

也许这会对你有帮助吗?