Найти в MySQL свободное число?

title это разные пятизначные числа 00001...

  • title
  • 00001
  • 00002
  • 00003
  • 00005
  • .....

Как можно найти первое(наименьшее) т.е 00004 свободное число?

$rel = $db->super_query("select title+1 from dle_post a where not exists
(select 1 from dle_post b where b.title=a.title+1) order by title limit 1");
echo $rel; 

Ответы (0 шт):