I have two tables: accounts payable and accounts receivable. The two tables have: code, description, date, datepagamento, data collection and value.
How do I make a query to get the data of the two tables by sorting by the date?
I was using union :
SELECT
codigo,
descricao,
dataVencimento,
dataEntrada,
valor
FROM
contasReceber
WHERE
status= "pago"
UNION ALL
SELECT
codigo,
descricao,
dataVencimento,
dataSaida,
valor
FROM
pagamento
order by dataVencimento
But I could not think of a way to differentiate the inputs from the outputs. Because I need to display this data, for example:
Codigo Descrição Pago Recebido
1 farmacia 20,00 -
2 aluguel - 30,00
How can I do this using javascript + php + mysql ?