note 97861 deleted from function.mysql-data-seek by danbrown

From: Date: Wed, 12 May 2010 15:53:15 +0000
Subject: note 97861 deleted from function.mysql-data-seek by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169188@lists.php.net to get a copy of this message
Note Submitter: srynningb at yh dot com ---- 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.

« previous php.notes (#169188) next »