I want to create a view for this sql statement which previously works fine. But when I create this into a view, A error prompting out showing that, "View's SELECT contains a variable or parameter." Can anyone tell me where the error falls as I am quite new to views in MySQL. Thanks!
CREATE VIEW `satsschema`.`viewTimeBreak` AS
SELECT a.EmpName, CONCAT(b.StartTime, '-', b.EndTime) AS ShiftTime, CONCAT(a.EmpTime, '-', ADDTIME(a.EmpTime, '0 1:0:0.000000')) AS BreakTime, a.Break,
a.EmployeeOnBreak, '' AS SignIn, '' AS SignOut
FROM satsschema.employeeslot a INNER JOIN
satsschema.ufis b ON b.UFISID = a.UFISEmpGroup
WHERE (a.AllocationDate = @AllocationDate) AND (a.LocationName = @LocationName) AND (a.Break = 1)
GROUP BY a.EmpName
This part shows the error when I tried to create a view using the sql statement.
You cannot have variables like @AllocationDate and @LocationName used in the query definition of a view itself.
Instead what you can do is
And then put the conditions at the time of using the view
so your SELECT statement would be