0
我有與CASE
聲明在此過程中的麻煩:MySQL的Case語句不起作用
DELIMITER //
CREATE PROCEDURE getRowsByHourHalfday(xhour smallint)
BEGIN
SET @twelveless = xhour - 12;
SELECT CASE
WHEN (xhour, > 11) THEN SET @realhour = (xhour - 12);
ELSE SET @realhour = xhour;
END CASE;
SET @first = @realhour * 60;
SET @next = @first + 59;
SELECT * FROM mydb.halfday WHERE minutepart BETWEEN @first AND @next;
END //
DELIMITER ;
這是我想做的僞代碼:
if hour > 11 then
set newhour = hour - 12;
set first = newhour * 60;
else
set first = hour * 60;
endif
select * from halfday where minutepart between first and (first + 60);
@亞當這個社區有時很迂腐...... – batman