I want to query something like this:
SELECT id
FROM reparacoes
WHERE edit_data= (select max(edit_data)
from reparacoes
where id_reparacao= (select id_reparacao from reparacoes));
However the subquery select id_reparacao from reparacoes returns more than 1 row (as expected) and the query doesn't work. Should I do this with joins? if yes, how?
So here's how it works: every time I edit a "reparacoes" row(at my website), I INSERT a new one(i don't UPDATE) and a new ID is created as well as a edit_data(which is the datetime of the edit) but the id_reparacoes stays the same.
I want a query that returns the ID from reparacoes where edit_data is the most recent from a given id_reparacao. but I have more then one id_reparacao and i want this to query for all id_reparacao(that's why i tried ...where id_reparacao= (select id_reparacao from reparacoes)
PS: sorry, I know this has already been questioned/answered many times but I couldn't find anything that could help me.
inoperator ?