Home > Archive > PHP SQL > February 2006 > Increment Optimization
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Increment Optimization
|
|
| afrinspray 2006-02-08, 9:16 am |
| I'm trying to optimize this situation... I have a page that has a bunch
of categories on it, each with an up and down arrow for re-ordering.
Each category has a field, intCategoryOrder, which is initially zero
for every category.
When the user first presses up or down on a category, I want to
populate the intCategoryOrder field for all categories so the first
category order is one, the second is two, etc... Is there a way to do
this in one SQL statement instead of x update statements? I'm using
MySQL 5.0.x.
Thanks,
Mike
| |
| ZeldorBlat 2006-02-08, 9:16 am |
| afrinspray wrote:
> I'm trying to optimize this situation... I have a page that has a bunch
> of categories on it, each with an up and down arrow for re-ordering.
> Each category has a field, intCategoryOrder, which is initially zero
> for every category.
>
> When the user first presses up or down on a category, I want to
> populate the intCategoryOrder field for all categories so the first
> category order is one, the second is two, etc... Is there a way to do
> this in one SQL statement instead of x update statements? I'm using
> MySQL 5.0.x.
>
> Thanks,
> Mike
A solution that didn't involve a bunch of update statements would
require the database to somehow "know" what the order should be (as in
a default). Unless you have some implicit ordering you'd like to start
with (for instance, the category names sorted alphabetically) you'll
need to have a bunch of update statements.
|
|
|
|
|