You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
Proposed solution: include "display" column on the SELECT.
CREATE DEFINER=`root`@`%` PROCEDURE `catalog_get_products_on_department`(
IN inDepartmentId INT, IN inShortProductDescriptionLength INT,
IN inProductsPerPage INT, IN inStartItem INT)
BEGIN
PREPARE statement FROM"SELECT p.product_id, p.name, IF(LENGTH(p.description) <= ?, p.description, CONCAT(LEFT(p.description, ?), '...')) AS description, p.price, p.discounted_price, p.thumbnail, p.display 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).
The text was updated successfully, but these errors were encountered: