SQLite Forum

Getting rid of double DATE()
CTE to the rescue:
    WITH now AS (
	    SELECT DATE('now', '+1 day', 'localtime') AS val
    UPDATE selectRandom
    SET    lastUsed = (SELECT val FROM now), 
           lastUsedIdx = (
		SELECT IFNULL(MAX(lastUsedIdx), 0) + 1
        FROM   selectRandom
        WHERE  lastUsed == (SELECT val FROM now)
    where description == 'White Tea'

I need to use the IFNULL instead of the double MAX.