0
I’m trying to use 2 if
but the result always returns empty, when I use only one if
he will.
SELECT aci_codigo, aci_valor_pagamento, bai_fk_pes_codigo,
aci_tipo_pagamento, aci_fk_ftm_codigo, aci_nosso_numero,
ftm_descricao, ftm_codigo, bai_fk_bor_codigo,
bor_tipo,bai_data_cadastro
FROM acordo_item
INNER JOIN baixa ON bai_fk_aci_codigo = aci_codigo
INNER JOIN bordero ON bor_codigo = bai_fk_bor_codigo
LEFT JOIN financeiro_tipo_movimentacao ON ftm_codigo = aci_fk_ftm_codigo
WHERE aci_status = 'B'
AND
IF(aci_tipo_pagamento = "PE", bai_data_cadastro, bor_data_criacao) >= '2016-11-22 00:00:00'
AND
IF(aci_tipo_pagamento = "PE", bai_data_cadastro, bor_data_criacao) <= '2016-11-22 00:00:00'
GROUP BY aci_codigo
What is the purpose of the aci_type payment constraint? Note that you built something like "A >= x and A <= x". The constraint will only be true if A = x. That is, only if the date selected is 11/22/2016.
– José Diz