您的 MySQL 版本是ONLY_FULL_GROUP_BY
模式启用这意味着(在 MySQL 5.7.5 及更高版本中)任何查询使用DISTINCT
and ORDER BY
将需要以下列ORDER BY
也能在SELECT
查询的一部分。
修复方法是添加scheduleDate
to the SELECT
您的部分查询如下所示:
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetAllEventIdList_SP`(in skillId varchar(50),in offsetvalue int,in recordlimit int,out totalcountquery text)
BEGIN
set @whereClause=" ";
SET @skills=concat('"',skillId,'"');
if(skillId is not null and skillId <>"" and skillId <>0) then
set @whereClause=concat(@whereClause," where skill_id in (",@skills ,")");
end if;
set totalcountquery=concat("select count(distinct (eventId)) from EventAttachmentList_View ",@whereClause);
if(offsetvalue<recordlimit) then
set @SqlQuery=concat("select distinct (eventId),scheduleId,scheduleDate from EventAttachmentList_View ",@whereClause, " order by scheduleDate desc ", " limit " ,recordlimit , " offset 0");
PREPARE querystatement FROM @SqlQuery;
EXECUTE querystatement;
DEALLOCATE PREPARE querystatement;
else
set @SqlQuery=concat("select distinct (eventId),scheduleId,scheduleDate from EventAttachmentList_View ",@whereClause, " order by scheduleDate desc ", " limit " ,recordlimit , " offset ", offsetvalue);
PREPARE querystatement FROM @SqlQuery;
EXECUTE querystatement;
DEALLOCATE PREPARE querystatement;
end if;
END