Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Shelly

Aspas simples em Mysql.

Recommended Posts

Boa tarde pessoal !

 

Tenho que fazer um select da forma abaixo mas estou tendo problemas com as aspas do ifnull e da clausula where também.

Se verifico o conteúdo da variável @SQLString onde tem '' ele fica como \'. Já tentei aspas duplas usar o replace no final dos comandos e até agora não tive sucesso. Alguém poderia me ajudar ?

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

SET @nomecli = '%pedro%';
SET @SQLString =
CONCAT(' select cli_id, cli_nome, ifnull(comercial.clt_tel,'' ) comercial, ifnull(celular.clt_tel,'') celular, ',
' ifnull(residencial.clt_tel,'') residencial, ifnull(cli_EmailPri,'') EmailPrincipal, ifnull(cli_EmailSec,'') EmailSecundario ',
' from clientes ',
' left join clientes_telefone comercial ',
' on comercial.clt_cliid = cli_id ',
' and comercial.clt_telid =1 ',
' left join clientes_telefone celular ',
' on celular.clt_cliid = cli_id ',
' and celular.clt_telid =2 ',
' left join clientes_telefone residencial ',
' on residencial.clt_cliid = cli_id ',
' and residencial.clt_telid =3 ',
' left join clientes_atividade ',
' on clientes_atividade.cla_cliid = cli_id '
);
if(nomecli<>'' or telefone<>'' or atividade<>0 or tipo<>0) then
SET @SQLString = CONCAT(@SQLString,' where ');
if (nomecli<>'') then
SET @SQLString = CONCAT(@SQLString,' cli_nome like ', @nomecli);
end if;
end if;

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.