user1610075
user1610075

Reputation: 1641

Select older date

I have a database limited to n records, if a new record has to be inserted and there's no space I want to delete the oldest one, mind that there could be more than a record with same date: in this case I just remove the first one. Is it possibile to achieve something like this in sqllite which doesn't have date support?

Upvotes: 0

Views: 86

Answers (1)

Dany Y
Dany Y

Reputation: 7041

First of all, to be able to sort your records by date, you have to insert them in the format YYYYMMDD or YYYYMMDDHHmm Now to get one of oldest ones with same date, you can do this :

    SELECT * FROM URTABLE WHERE 
    LAST_UPDATE_DATE = (SELECT MAX(LAST_UPDATE_DATE) FROM URTABLE) LIMIT 1

Upvotes: 2

Related Questions