I'm doing a procedure, I need to put a varchar variable in the query, but it does not go with the single quotation marks, I've tried concatenating it or something like that, but it's no use:
set @comando := concat(@comando, '"'); //ao contrário tbm
set @comando := concat(@comando, classe);
set @comando := concat(@comando, '"');
I've already put triple quotation marks too:
set @comando := concat(@comando, '''classe''');
What better way to concatenate or make MySQL recognize as a varchar?
Code:
delimiter $$
create procedure eixos_caminhao (in classe varchar(3))
begin
set @comando := 'select count(*) as qtdeCaminhoes';
set @comando:= concat(@comando, ' from tb_vbv where classe = ');
set @comando := concat(@comando, classe);
PREPARE myquery FROM @comando;
EXECUTE myquery;
end $$
delimiter;