How to nest an if statements in another if statemtn in mysql -
i can not life of me understand why "type = 1" being ignored. type being set above , have verified type either 1 or 2. can set type = 5 , still executes in if statement. if ignores if type = 1 then. can nest if statement withen mysql?
delimiter $$ create definer=`root`@`localhost` procedure `select_player`(teamid int) block1: begin -- outer block declare done int default false; declare type int; declare check_pos text; declare curse2 cursor select pos, sort1 dutil_pos_sort; declare continue handler not found set done := true; open curse2; rd_loop: loop fetch curse2 check_pos, type; if done leave rd_loop; end if; block2: begin -- inner block declare done1 int default false; declare pl_id, comp int; declare dl_pos text; declare curse1 cursor select p.player_id,substring_index(substring_index(p.pos,'/',1),'/',-1) segment1 dutil_players p, dutil_picks k k.player_id = p.player_id , k.team_id=teamid; declare continue handler not found set done1 := true; open curse1; read_loop: loop fetch curse1 pl_id, dl_pos; if done1 leave read_loop; end if; if type = 1 if dl_pos concat("%",check_pos,"-","%") select "match",pl_id, dl_pos, check_pos; leave read_loop; else select "no match", check_pos; end if; else if dl_pos binary concat("%",check_pos,"%") select "match",pl_id, dl_pos, check_pos; leave read_loop; else select "no match", check_pos; end if; end if; end loop read_loop; close curse1; end block2; end loop rd_loop; close curse2; end block1
Comments
Post a Comment