Click to See Complete Forum and Search --> : [RESOLVED] INSERT logic assistance requested


WolfShade
11-02-2007, 12:23 PM
Hello, all.

I'm sure this is really simple, but I just can't seem to wrap my brain around it.

What I'm trying to do is a simple INSERT query into a table that has a column for sort ordering the items in it. I've got two items that have sort order values 1999998 and 1999999, as I always want them to appear last. What I would like to do is get the highest sort order value under 1999998 so I can add 1 to it and make it the next sort order for the insert.

Is there a way to get a MAX value that isn't the MAX???

Thanks,

^_^

WolfShade
11-02-2007, 01:35 PM
Nevermind. It didn't occur to me that I could limit the scope of the select when choosing the MAX.


SET @so = (SELECT MAX(sortOrder) FROM Usr_Nav_Top WHERE sortOrder < 1999998)

^_^