Выборка элементов по порядку на основе сортировки

Задача.
Мы имеем ряд идентификаторов полученных в запросе
1
23
3535
2423423
45345345
54645645
Необходимо данную выборку превратить в последовательность чисел от 1 и до ....
Решение

  1. SET @rank=0;
  2. select nid,@rank:=@rank+1 AS number
  3. FROM vp.node
  4. where type = 'test'
  5. order by nid;
Russian
Категория: 
The code has been tested and works
Мультитег: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Target Image