At 5:05 PM +0300 1999-12-16, Dmitry Sivachenko wrote:
>I need to make a counter using MySQL: an integer value, that is incremented
>by 1 every time I _select_ it's value.
>Using PostgreSQL, I did this like
>psql -q -t -c "select nextval('access_count');" -d DBNAME
>where access_count it a sequence.
>In MySQL I do the following:
>update sequence set id=LAST_INSERT_ID(id+1);
>select id from sequence;
>where 'sequence' is an integer field.
>Is there an analogous function in MySQL (like nextval)?
>How can I archive the same result, I mean select and increment an integer
>in _one_ operation?
Why is UPDATE + SELECT unsuitable? The value you get is specific to
your specific client session; it cannot be affected by update activity
performed by other clients.
Paul DuBois, paul@stripped