【问题标题】:sql on double select without join statement没有连接语句的双重选择的sql
【发布时间】:2013-12-23 17:59:34
【问题描述】:

我想全选productreview item和productimage.productimage,怎么选?如果我不使用双选,它可能会显示明亮的实体数量。请帮我选择 productimg 并在 productreview 上选择一个项目

我做的方式无法得到我想要的结果

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'`

【问题讨论】:

  • 向我们展示您迄今为止所做的尝试。顺便说一句,您以前在查询中使用过JOINs。
  • 请向我们展示一些示例输入和您的查询的预期输出。

标签: mysql asp.net sql


【解决方案1】:

您可以根据 productID 列将 ProductReview 表与 ProdutImage 表连接起来。这是 SQL 查询

SELECT PR.*,PI.ProductImg FROM ProdcutReview AS PR INNER JOIN ProdcutImg AS PI
ON PR.ProductID = PI.ProductID

【讨论】:

    猜你喜欢
    • 2010-12-28
    • 1970-01-01
    • 2010-12-28
    • 1970-01-01
    • 1970-01-01
    • 2020-04-18
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    相关资源
    最近更新 更多