note 97861 added to function.mysql-data-seek
| From: | srynningb at yh dot com | Date: | Wed, 12 May 2010 15:19:49 +0000 |
| Subject: | note 97861 added to function.mysql-data-seek | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169187@lists.php.net to get a copy of this message | ||
Here's a handy way to sequentially number the rows of any query result starting with 0, so in
code you can easily save a current row number if you need to jump back to it later with
mysql_data_seek().
SELECT <field1>,<field2>,etc,@rownum:=@rownum+1 as rownumber FROM <table1> JOIN
<table2> JOIN etc JOIN (SELECT @rownum:=-1) as start WHERE <condition1> AND
<condition2> AND etc
This will add a column called "rownumber" to the result which counts up starting with 0 on
the first row. Note: the "start" alias is required because it's a derived table even
though nothing refers to it.
----
Server IP: 69.147.83.197
Probable Submitter: 32.170.211.239
----
Manual Page -- http://www.php.net/manual/en/function.mysql-data-seek.php
Edit -- https://master.php.net/note/edit/97861
Del: integrated -- https://master.php.net/note/delete/97861/integrated
Del: useless -- https://master.php.net/note/delete/97861/useless
Del: bad code -- https://master.php.net/note/delete/97861/bad+code
Del: spam -- https://master.php.net/note/delete/97861/spam
Del: non-english -- https://master.php.net/note/delete/97861/non-english
Del: in docs -- https://master.php.net/note/delete/97861/in+docs
Del: other reasons-- https://master.php.net/note/delete/97861
Reject -- https://master.php.net/note/reject/97861
Search -- https://master.php.net/manage/user-notes.php