CodeIgniter Forums
mysql help - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: mysql help (/showthread.php?tid=18936)

mysql help - El Forum - 05-22-2009

how can i add from mysql a incrementing value to each row i get from a query ?
i'm not talking about auto incrementing a existing value.

example :
Quote:select round((sum( / count(,2) AS vote, count( AS nrvotes, ("value"+1) as position FROM votes, users WHERE = votes.person order by vote,nrvotes,position desc

where "value" is not in any of the 2 tables is just the place in the results

this is just a example my query is much more complex

i want to add a value starting from 1 an incrementing it for each row.
i need to do this from inside the query not from php

mysql help - El Forum - 05-22-2009

What are the benefits of performing this action within SQL?
To solve this problem you can try a subquery. It may or may not work:
  (SELECT COUNT(*) FROM table WHERE something = something_else) + 1 AS position
  column = something