setting a offset value for a particular id??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemantc87
    New Member
    • Mar 2010
    • 13

    #1

    setting a offset value for a particular id??

    i am designing a website in which i need to generate an offset value for a product(and store it in database) between 1 to 999 for every product id i store into my database from a textbox..but first it must check if a particular value starting from 1 to 999 is already taken if yes then it generates the next available number between 1 to 999..the problem is how can i retrieve and check the available numbers already stored in offset column of my database and then generate next available number?

    for example: if 1 ,2 ,3 ,6,8 numbers are taken offset value generated should be 4 and not 7..

    though its difficult to explain but if u understand my question i wuld be glad to have some code of how to achieve it??
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    It sounds like you're looking to create a SQL query that uses the MAX function:

    Code:
    SELECT MAX(offsetValueColumn) as "HighestOffset"
    FROM myTable;
    The MAX function returns the maximum value of an expression.

    -Frinny

    Comment

    Working...