Syntax\n------\n\nPREVIOUS VALUE FOR sequence_name\n\nDescription\n-----------\n\nGets the most recent value in the current connection generated from a sequence.\n\n If the sequence has not yet been used by the connection, PREVIOUS VALUE FOR returns NULL (the same thing applies with a new connection which doesn't see a last value for an existing sequence).\n If a SEQUENCE has been dropped and re-created then it's treated as a new SEQUENCE and PREVIOUS VALUE FOR will return NULL.\n Returns NULL if the sequence is complete.\n FLUSH TABLES has no effect on PREVIOUS VALUE FOR.\n Previous values for all used sequences are stored per connection until connection ends.\n PREVIOUS VALUE FOR requires the SELECT privilege.\n\nExamples\n--------\n\nCREATE SEQUENCE s START WITH 100 INCREMENT BY 10;\n\nSELECT PREVIOUS VALUE FOR s;\n+----------------------+\n| PREVIOUS VALUE FOR s |\n+----------------------+\n|                 NULL |\n+----------------------+\n\nThe function works for sequences only, if the table is used an error is generated\nSELECT PREVIOUS VALUE FOR t;\nERROR 4089 (42S02): 'test.t' is not a SEQUENCE\n\nCall the NEXT VALUE FOR s:\nSELECT NEXT VALUE FOR s;\n+------------------+\n| NEXT VALUE FOR s |\n+------------------+\n|              100 |\n+------------------+\n\nSELECT PREVIOUS VALUE FOR s;\n+----------------------+\n| PREVIOUS VALUE FOR s |\n+----------------------+\n|                  100 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-structure/sequences/sequence-functions/previous-value-for-sequence_name