Error code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL Server version for the right syntax to use near
The error is reported because the if else statement in MySQL procedure uses the begin end statement. If it is removed, it is OK.
Delimiter $ use 'sportgbmj '$ drop procedure if exists 'SP _ web_addmiddayrank' $ create definer = 'root' @ '% 'Procedure 'SP _ web_addmiddayrank '() begin/* revision record: Supervisor version revised by revision date revision description 2.161.0.0 2013-06-15 query current Am-Am rankings this SP is executed after the end of the current competition prerequisites: 1: must complete 10 (inclusive) bureaus or above in one field */declare I _date date; declare I _starttime time; declare I _endtime time; Set I _date = now (); Set I _endtime = now (); if (I _endtime> '22: 30') then Begin /* Night arena */set I _starttime = '21: 30'; Set I _endtime = '22: 30 '; End Else Begin /* Midday field */set I _starttime = '12: 30'; Set I _endtime = '13: 30 '; End End if; create temporary table tmp_rank (ID int not null auto_increment -- Auto increment, userid int -- User ID, beans int -- bean summary, rounds tinyint -- number of Bureaus summary, posttime time -- time (the player's last time in the game) engine = MyISAM; insert into tmp_rank (userid, beans, rounds, posttime) Select userid, sum (case when consume> 0 then consume else 0 end) Beans, count (userid) rounds, max (posttime) as posttime from score as s inner join scorelist as SL on S. PID = SL. PID where roomid in ('20140901') and (postdate = I _date and posttime> = '12: 30: 00' and posttime <= '13: 30: 00 ') group by userid having (rounds> = 10) order by beans DESC, maxtime ASC limit 500;/* Insert a table */insert into hf_playranklist (userid, rank, beans, rounds, postdate, posttime) Select userid, beans, rounds, I _date, posttime from tmp_rank;/* Insert prize table */INSERT INTO hf_prizelist (userid, status, prizeid, receivetime, postdate) Select userid, 0, (case when Id> = 11 then 4 when (ID> = 3 and ID <= 10) then 3 when id = 2 then 2 when id = 1 then 1 end) as prizeid, beans, rounds, posttime from tmp_rank as R where rank> = 30; end $ delimiter;