![]() |
mysql help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: mysql help (/showthread.php?tid=18936) |
mysql help - El Forum - 05-22-2009 [eluser]quasiperfect[/eluser] 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(votes.vote) / count(votes.id)),2) AS vote, count(votes.id) AS nrvotes, ("value"+1) as position FROM votes, users WHERE users.id = 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 [eluser]xzela[/eluser] Hi, 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: Code: SELECT |