-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
CREATE PROCEDURE catalog_get_products_on_department(
IN inDepartmentId INT, IN inShortProductDescriptionLength INT,
IN inProductsPerPage INT, IN inStartItem INT)
BEGIN
PREPARE statement FROM
"SELECT DISTINCT p.product_id, p.name,
IF(LENGTH(p.description) <= ?,
p.description,
CONCAT(LEFT(p.description, ?),
'...')) AS description,
p.price, p.discounted_price, p.thumbnail
FROM product p
INNER JOIN product_category pc
ON p.product_id = pc.product_id
INNER JOIN category c
ON pc.category_id = c.category_id
WHERE (p.display = 2 OR p.display = 3)
AND c.department_id = ?
ORDER BY p.display DESC
LIMIT ?, ?";
SET @p1 = inShortProductDescriptionLength;
SET @p2 = inShortProductDescriptionLength;
SET @p3 = inDepartmentId;
SET @p4 = inStartItem;
SET @p5 = inProductsPerPage;
EXECUTE statement USING @p1, @p2, @p3, @p4, @p5;
END$$The returned error message says:
Error Code: 3065. Expression # 1 of ORDER BY clause is not in SELECT list, references column 'ecommerce.p.display' which is not in SELECT list; this is incompatible with DISTINCT
Please clarify why it is used the condition (p.display = 2 OR p.display = 3).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels