mysql - 没有 join 语句的双重选择的 sql

标签 mysql asp.net sql

我想选择所有的productreview项和productimage.productimage,如何选择?如果我不使用双选,它可能会显示明亮的实体数量。请帮我选择产品并在产品评论上选择一个项目

enter image description here

我这样做无法得到我想要的结果

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/

相关文章:

java - Hibernate 和 MySQL 超出锁定等待超时(使用 Play Framework )

C# MySQL - "Update"正在选择每一行/所有内容

c# - 如何在 asp.net mvc 中选择一个选择列表项?

mysql - 如何仅对表中的特定行求和

sql - 只读用户可以创建表

mysql - 如何处理从某个表中删除多个对象

MySQL,如果唯一记录被删除怎么办?

asp.net - 是否有商业部署和使用的基于 .NET CAS(代码访问安全)的应用程序?

sql - 查询超时

mysql - R中的多个数据库连接