0
CREATE DEFINER=`root`@`localhost` PROCEDURE `test2`(in employeeId text)
BEGIN
set @SQLQuery =CONCAT("select groupId,eventId,scheduleId,description,events,eventType,
scheduledDate,name,designation,image,skills,duration,status,attachmentPath,
case when scheduledDate < now() and (select count(*) from event_request where
event_id=eventId and employee_code='",employeeId,"')>0 then 1
when scheduledDate < now() and (select count(*) from event_request where
event_id=eventId and employee_code='",employeeId,"')=0 then 0
else '' end as hasRequested ,(SELECT actual_attendance_status_id FROM TJU.event_attendees_mapping where
scheduleId=event_schedule_id and employee_code='",employeeId,"')
as attendingStatus,
case
when
(select count(*) from event_attendees_mapping where
event_schedule_id=scheduleId and employee_code='",employeeId,"')>0 then 1
else 0 end as isMyEvent,meetingRoom from EventList_View ", "and 1=1");
select @SQLQuery;
END
これは私の動的従業員IDを渡しています。これは私がこのプロシージャコール( "TJU_741")を呼び出したときの動的クエリのプロシージャです。mysqlのselectクエリでcon-cat動的IDを取得する方法
その後、私のクエリはあなたがそれはTJU_741は「私のクエリは、従業員IDのためになるようにCONCATする方法を私に提案してくださいする必要がありながら、各社員コードが「この「」TJU_741」のようになっていることがわかります
ここselect groupId,eventId,scheduleId,description,events,eventType,
scheduledDate,name,designation,image,skills,duration,status,attachmentPath,
case when scheduledDate < now() and (select count(*) from event_request where
event_id=eventId and employee_code=''TJU_741'')>0 then 1
when scheduledDate < now() and (select count(*) from event_request where
event_id=eventId and employee_code=''TJU_741'')=0 then 0
else '''' end as hasRequested ,(SELECT actual_attendance_status_id FROM TJU.event_attendees_mapping where
scheduleId=event_schedule_id and employee_code=''TJU_741'')
as attendingStatus,
case
when
(select count(*) from event_attendees_mapping where
event_schedule_id=scheduleId and employee_code=''TJU_741'')>0 then 1
else 0 end as isMyEvent,meetingRoom from EventList_View and 1=1
なり'TJU_741'
'employeeId'列はすでに一重引用符でエスケープされているようですので、連結文字列内の一重引用符を削除する必要がありますか? –