我想选择所有的productreview项和productimage.productimage,如何选择?如果我不使用双选,它可能会显示明亮的实体数量。请帮我选择产品并在产品评论上选择一个项目
我这样做无法得到我想要的结果
select distinct `productreview.userid,
productreview.productid,
productreview.producttitle,
productreview.productreview,
productreview.recommend,
productreview.reviewdate,
productreview.posted,
productimage.productimg
from productreview,product,productstock,productimage
where productreview.productid=product.productid AND
product.productid=productstock.productid and
productstock.productid=productimage.productid and
productstock.productcolortype = productimage.productcolortype and
productimage.productcolortype='type1'`
最佳答案
您可以根据productID列将ProductReview表与ProdutImage表连接起来。这是 SQL 查询
SELECT PR.*,PI.ProductImg FROM ProdcutReview AS PR INNER JOIN ProdcutImg AS PI
ON PR.ProductID = PI.ProductID
关于mysql - 没有 join 语句的双重选择的 sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20748769/