Insert sql with rule WHERE NOT EXISTS does not work

0

This insert below only works until the first "Where" rule then does not work anymore

Example

WHERE descricao ='$ccusto'  // funciona perfeitamente. Mas se uso o where abaixo

WHERE descricao ='$ccusto' AND id_transfer ='$id_transfer' AND id_empresa='$id_empresa')");
                           // já não funciona


echo $id_transfer22 = 555;
echo $id_empresa = 555; 
echo $ccusto = 'obaoba';
echo $id_novo8= 555;
$sql = mysql_query ("INSERT INTO c_custo(id_transfer,id_empresa,descricao,cod) 
SELECT '$id_transfer22','$id_empresa','$ccusto','$cod' 
FROM DUAL
WHERE NOT EXISTS(SELECT descricao,id_empresa,id_transfer FROM c_custo
WHERE descricao ='$ccusto' AND id_transfer ='$id_transfer' AND id_empresa='$id_empresa')");

What can I be doing wrong?

    
asked by anonymous 22.02.2017 / 03:13

0 answers