1
I have a little doubt and difficulty in trying to solve my problem, I have the following query:
SELECT
`PcldCliente`.`id`,
`PcldCliente`.`nome`,
`PcldCliente`.`agencia_id`,
`PcldMain`.`id`,
`PcldMain`.`cliente_id`,
`PcldMain`.`saldo_devedor`,
`PcldMain`.`motivo`,
`PcldMain`.`data_inicio`,
`PcldDespesa`.`id`,
`PcldDespesa`.`cliente_id`,
`PcldDespesa`.`atual`,
`PcldDespesa`.`projetado`,
`PcldDespesa`.`data_inicio`,
`PcldObservacoes`.`id`,
`PcldObservacoes`.`cliente_id`,
`PcldObservacoes`.`observacao`,
`PcldObservacoes`.`created`,
`PcldSaldo`.`id`,
`PcldSaldo`.`cliente_id`,
`PcldSaldo`.`anterior`,
`PcldSaldo`.`atual`,
`PcldSaldo`.`projetado`,
`PcldSaldo`.`data_inicio`
FROM
`mpf`.`pcld_cliente` AS `PcldCliente`
LEFT JOIN
`mpf`.`pcld_main` AS `PcldMain` ON(
`PcldMain`.`cliente_id` = `PcldCliente`.`id`
)
LEFT JOIN
`mpf`.`pcld_despesa` AS `PcldDespesa` ON(
`PcldDespesa`.`cliente_id` = `PcldCliente`.`id`
)
LEFT JOIN
`mpf`.`pcld_observacoes` AS `PcldObservacoes` ON(
`PcldObservacoes`.`cliente_id` = `PcldCliente`.`id`
)
LEFT JOIN
`mpf`.`pcld_saldo` AS `PcldSaldo` ON(
`PcldSaldo`.`cliente_id` = `PcldCliente`.`id`
)
WHERE
`PcldMain`.`data_inicio` = '2016-03-07' AND `PcldDespesa`.`data_inicio` = '2016-03-07' AND `PcldSaldo`.`data_inicio` = '2016-03-07' AND `PcldObservacoes`.`created` = '2016-03-10'
What I want?
I want to return all Customers who have the records with the start dates, but I want you to return all Notes to the specified date, regardless of whether they exist or not. Only it returns only those that have the date specified, if it does not have the record in the table PcldObservacoes
he is not returned and stands outside.
What can I do?
Remove your Where put it on the ON of your tables ...
ON(

Pcldmain.
cliente_id=
Pcldcliente.
idAND
Pcldmain.
start date= '2016-03-07' AND
Pclddespesa.
start date= '2016-03-07'
)– Marco Souza