我收到此错误:
错误1064(42000):您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以在第1行的'NULL'附近使用正确的语法
我正在使用存储过程来检索数据,在这种情况下,我正在使用分页
这是我的存储过程代码:
CREATE DEFINER=`root`@`%` PROCEDURE `usp_get_product_wall_details`(
IN `in_user_id` INT,
IN `in_product_name` VARCHAR(50),
IN `in_category_id` INT
,
IN `in_order_by` VARCHAR(50),
IN `in_order_type` VARCHAR(50),
IN `in_page_no` INT,
IN `in_limit` INT
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
BEGIN
DECLARE var_offset INT;
DECLARE var_limit INT DEFAULT 10;
IF in_limit != 0 THEN
set var_limit = in_limit;
END IF;
set var_offset = (in_page_no - 1) * var_limit;
set @sql = '';
set @query = '';
set @query= concat("select SQL_CALC_FOUND_ROWS p.id,p.product_name,p.seller_count,p.rating,p.rating_count,pii.image_url,
padem.product_mrp,padem.minimum_selling_price,max(padem.discount_price) as discount_price,
max(padem.discount_percentage) as discount_percentage,pade.enum_value,padem.id as enum_id
from product p
inner join abc padem on padem.product_id = p.id
INNER JOIN cd pii ON padem.product_id = pii.product_id
inner join ef pade on pade.id = padem.attribute_dropdown_enum_id
where p.`status` = 1 and pii.is_thumbnail = 1 and padem.seller_id is not null and
pii.enum_mapping_id = (select pad.id from product_attribute_dropdown_enum_mapping pad where pad.product_id = padem.product_id and
pad.attribute_dropdown_enum_id = padem.attribute_dropdown_enum_id and pad.seller_id is null) and
padem.sort_order = (select min(sort_order) from product_attribute_dropdown_enum_mapping where product_id = padem.product_id group by product_id)
and (p.product_name like concat('tropicana','%') or p.product_name like concat('%','tropicana','%'))
group by p.id
order by ",in_order_by," ",in_order_type," limit ", var_offset,",",var_limit);
set @sql = concat(@sql,@query);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
执行此过程时出现错误。
但是同时,如果我在存储过程之外使用一些静态数据运行简单查询,则可以完美地检索数据。
表名已更改
答案 0 :(得分:0)
我通过重启MySQL服务器找到了解决方案:
sudo service mysql restart