0
Next, I need to bring in a query the last records that were not changed in the last 3 days from a ID
specific, ex.: (id_chamado_status = '1')
.
0
Next, I need to bring in a query the last records that were not changed in the last 3 days from a ID
specific, ex.: (id_chamado_status = '1')
.
0
As far as I can tell, there’s no way to pull "that hasn’t been tampered with" records from the bank. If someone changes the records it will simply be changed in the bank (it is enough that the person has permission).
If you want to fetch the date of "3" days ago, at the time you enter your data you should also save the insertion date, for example in a column of type DATE
with a specific name, here I will use the name DT_REGISTRO
and then retrieve the data:
SELECT * FROM <nome_sua_tabela> where DT_REGISTRO > 3
I forgot to inform, but I have a table that generates history if these records are changed.
edit the question and place the table images and respective fields, and the table of changed records and respective fields
You can select from the original table and bring records that are NOT in the second table("left Join") and use Where(from three days) from the first table.
0
To search for first or last record it is necessary to first order the query. Filter the result and then "take" the return.
Note. To search the last records, order the query in descending form.
Example:
SELECT CAMPO1, CAMPO2
FROM TABELA
WHERE FILTRO
ORDER BY CAMPO_DE_ORDENACAO DESC
LIMIT NUMERO_DE_REGISTROS
Research source: Documentation My SQL - Limit
Browser other questions tagged mysql sql
You are not signed in. Login or sign up in order to post.
this in a select field ?
– Victor
that’s right (Victor)
– Skaylle Barreto
there is some date field in this same table, where the date that was entered is stored ?
– Victor
@Skayllebarreto vc has some field that saves the modification dates?
– Lucas Souza
If possible, include table names, select example
– Alexandre Cavaloti
@Lucassouza I have a history table that is fed by an INSERT if any changes are made to the application.
– Skaylle Barreto
@Skayllebarreto I think it would be easier for you to create a "Date" field, just to control it.. With a field just to control the update date, you create a Rigger and the bank itself already does this qd perform the update command... For you to scan the entire history table, it can get kind of heavy the query...
– Lucas Souza