I need to delete all dates from the database except the first two selected dates:
SELECT DateColumn FROM Table GROUP BY date(DateColumn) ORDER BY DateColumn DESC
I want all dates except the first two to be deleted in one request.
delete from table where DateColumn not in( SELECT DateColumn FROM Table GROUP BY date(DateColumn) ORDER BY DateColumn DESC LIMIT 2)
DELETE FROM Table WHERE DateColumn NOT IN (SELECT DateColumn FROM Table GROUP BY date(DateColumn) ORDER BY DateColumn DESC LIMIT 2);
Source: https://habr.com/ru/post/1536406/More articles:Compile F # source while working with Codedom? - .net-assemblyПолностью отключить/скрыть строку состояния на 4.4.2 - androidSearching for row indices where there are nonzero entries in sparse csc_matrix - pythonRemoving all rows from the database except the first tow lines in oracle - sqlDestroy the foreground notification when the service is killed - javaHow to make basic remote procedure call (RPC) in Telegram? - rpcScala nested flattening arrays - collectionsFiguring out where to add punctuation to bad user content? - language-agnosticUnable to interact with elements at adorner level - c #Determine the offset where the most constructive interference occurs - language-agnosticAll Articles