如何获得产品价格列的总和与referance到其他表列customer_id

时间:2016-12-22 08:45:37

标签: php mysql

我想获得.slick-test .slick-track { background: none !important; } .slick-test .slick-slide { background-color: #556677 !important; margin-right: 5px; padding: 3px; } 和我在SUM表中保存的购物车产品的特定客户的id产品价格。价格在cart表中。

表格结构如下:

products

我该怎么做?我使用的是以下CART TABLE cart_id, customer_id, product_id, product_qty PRODUCTS TABLE product_id, product_cat, product_title, product_desc, product_price, product_img mysqli代码,但它返回php

NUll

1 个答案:

答案 0 :(得分:1)

你不是指更多的东西:

"SELECT SUM(`product_price`) as total
FROM cart
INNER JOIN product ON product.id = cart.product_id
WHERE cart.customer_id = '$c_id'";

很难说,因为我们不知道你的数据库结构,但是像你一样加入表似乎毫无意义

更新:知道数据库结构后更改了查询