title: MySQL get row position in ORDER BY
body: <p>With the following MySQL table:</p>
  
  <pre><code>+-----------------------------+
  + id INT UNSIGNED             +
  + name VARCHAR(100)           +
  +-----------------------------+
  </code></pre>
  
  <p>How can I select a <em>single</em> row AND its position amongst the other rows in the table, when sorted by <code>name ASC</code>. So if the table data looks like this, when sorted by name:</p>
  
  <pre><code>+-----------------------------+
  + id | name                   +
  +-----------------------------+
  +  5 | Alpha                  +
  +  7 | Beta                   +
  +  3 | Delta                  +
  + .....                       +
  +  1 | Zed                    +
  +-----------------------------+
  </code></pre>
  
  <p>How could I select the <code>Beta</code> row getting the current position of that row? The result set I'm looking for would be something like this:</p>
  
  <pre><code>+-----------------------------+
  + id | position | name        +
  +-----------------------------+
  +  7 |        2 | Beta        +
  +-----------------------------+
  </code></pre>
  
  <p>I can do a simple <code>SELECT * FROM tbl ORDER BY name ASC</code> then enumerate the rows in PHP, but it seems wasteful to load a potentially large resultset just for a single row.  </p>