Ver originalset @ExistsUser = (select 1 from `ps_customer` where Exists(select * from `ps_customer` where id_customer = 3) LIMIT 1); IF @ExistsUser = 1 THEN SET @s = 1; ELSEIF @ExistsUser = NULL THEN SET @s = 0; END IF;