答案 0 :(得分:0)
CREATE PROCEDURE dbo.EditGrade
@Id int
,@TimeIn datetime
,@TimeOut datetime
,@Existing bit OUTPUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @CurrentTimeIn as datetime
DECLARE @CurrentId as int
SELECT @CurrentId = Id
FROM tblAttendance
WHERE TimeIn = @TimeIn
IF (@CurrentId <> @Id)
BEGIN
IF (SELECT COUNT(ISNULL(Id,0))
FROM tblAttendance
WHERE TimeIn = @TimeIn
SET @Existing = 0
ELSE
SET @Existing = 1
END
ELSE
BEGIN
SET @Existing = 0
END
IF @Name = ''
SET @Name = null
IF (@Existing = 0)
UPDATE tblAttendance
SET TimeIn = @TimeIn
--other column values here
WHERE Id = @Id
ELSE
--INSERT FROM tblAttendance query here
END
GO
这是从ms sql的存储过程,你只需将其转换为mysql版本。
请注意,日期时间类型也会检查秒数,因此请尽可能不包括秒数,否则它将呈现为不相同(例如,时间= 10:00:01,超时时间为10: 00:02将被渲染为不是相同的)