[英]MYSQL: Operand should contain 1 column(s)
Im trying to get a list of products order by the amount sold and by date... I also want to display the products that havent been sold in the list so I tried doing a subquery but MYSQL is giving me this message: 我正在尝试按销售数量和日期获取产品订单列表...我也想显示列表中尚未售出的产品,因此我尝试执行子查询,但MYSQL给出了以下消息:
Operand should contain 1 column(s) 操作数应包含1列
This is the query im using: 这是即时通讯使用的查询:
SELECT product.product_id, product.product_brand_id, product.product_model_id, product.product_subcategory_id, product.product_retail_price, product.product_wholesale_price
FROM product
WHERE product.product_subcategory_id = $subcategory_id
AND (SELECT SUM(product_sold.product_quantity) AS product_quantity_sold, SUM(product_sold.product_total_price) AS total_price_sold
FROM product
INNER JOIN product_sold
ON product.product_id = product_sold.product_id
INNER JOIN sales
ON sales.sales_id = product_sold.product_sales_id WHERE sales.sales_approved = '1' AND sales.sales_approved_time > '$start_timestamp' AND sales.sales_approved_time < '$end_timestamp')
The AND
operator expects a single value on either side, but you have this: AND
运算符的任一边都希望有一个值,但是您有:
WHERE product.product_subcategory_id = $subcategory_id
AND ( ... select that returns two columns)
The first operand is of the form X = Y
, so that's a Boolean that evaluates as true
or false
(or NULL
if the field is NULL
), but the second operand isn't a Boolean. 第一操作数的形式为
X = Y
,所以这是该评估为布尔值true
或false
(或NULL
如果该字段是NULL
),但第二个操作数不是一个布尔值。
To get this to work, you'll need to make the second operand of AND
into a single-valued expression. 要使其正常工作,您需要将
AND
的第二个操作数转换为单值表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.