Skip to content

Instantly share code, notes, and snippets.

@nosmall
Created November 1, 2016 15:38
Show Gist options
  • Save nosmall/8095a247566d267536454f585bc487a3 to your computer and use it in GitHub Desktop.
Save nosmall/8095a247566d267536454f585bc487a3 to your computer and use it in GitHub Desktop.
SQL get first free ID
(SELECT MIN(t1.UID + 1) AS id FROM task_read t1 LEFT JOIN task_read t2 ON t1.UID + 1 = t2.UID WHERE t2.UID IS NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment