1
I have two tables: bills payable and receivables. The two tables have: code, description, date, payment date, date of receipt and value.
Like I make a query to take the data of the two tables sorting by the date?
I was using the 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 couldn’t think of a way to differentiate the inputs of the exits. 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 it using javascript+php+mysql?
I didn’t understand how this query will work. Can you please explain? What is this 0 the received and this 0 paid? And this column type?
– L.J
@L.J Sorry for the delay, I was traveling, that 0 received, will generate a column with value 0 when the row comes from the accounts receivable table, and also for the other table. The type, just to differentiate the rows, and show you that you can generate other columns in select. When viewing the query result, you can know which row came from which table.
– Rovann Linhalis
Then it should not be in the first query 0 as paid pq it will ta selecting the accounts it will receive. And at the bottom that he is selecting the payments should not be 0 the received, since he is selecting payments so the received column has that 0?
– L.J
Got it now. What if I want to filter the due date or date between two dates. How would I use the BETWEEN in this query? Fis isso: dataexpiration between '01/08/2017' AND '30/08/2017' but is not working. It is giving error: Unknown column 'dataPackage' in 'Where clause'
– L.J
This was supposed to work but is not working. Unknown column 'dataexpiration ' in 'Where clause'
– L.J
@L.J tests now.
– Rovann Linhalis
Gave this error: Unknown column 'r. date 'in 'Where clause'
– L.J
are you sure this column exists in your table ? puts their structure there please
– Rovann Linhalis
It worked...was because I was using date format and was using DATE_FORMAT(r.expiration_expiration,'%d/%m/%Y') AS dataexpiration. Then I was getting dated. and not r.data_expiration Ai was giving this stick but now funfou. Vlw guy!!!
– L.J