Semi-OT: GETNEXT methodology in SQL?
Fairlight
fairlite at fairlite.com
Tue Jun 9 18:25:43 PDT 2009
On Tue, Jun 09, 2009 at 08:51:49PM -0400, Dan Coutu may or may not have
proven themselves an utter git by pronouncing:
> One method that jumps to mind immediately requires that you keep a
> counter value and then use it along with a syntax like this:
>
> select * from mytable limit 0,1;
>
> You then generate a sequence of select statements where you increment
> the zero by one (this is where the counter comes in.) This will let you
> walk through every record in the table, one at a time, with no unique
> index being used.
>
> Hmm, a little research shows that MySQL 5 now supports variables and
> stored procedures. So you ought to be able to do this:
>
> set @counter = 0;
> set @tablesize := select count(*) from mytable;
> while @tablesize > @counter
> select * from mytable limit @counter,1;
> end while;
>
> I hope this helps. Note that the record count is zero based and
> @tablesize is one based.
Where do you squeeze in the UPDATE? :)
mark->
More information about the Filepro-list
mailing list