Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004

    special auto-increment

    this is something that is probably very used on databases...

    there's a users table and a (for example) notes table... each user may have N notes... the notes table has "user_id" and "note_id" fields (both primary key)...
    is there an easy way to make the note_id auto-increment for each "user_id" (and not just 1,2,3,4...)?

    for example:
    you add a note for user_id=1, so the note_id=1
    then you add another note for user_id=1, note_id=2
    now you add a note for user_id=2, the note_id=1, not 3

    can this be done with mysql or the script must do it?


  2. #2
    Join Date
    Jan 2003
    It would need to be script/application-level. Is there a reason you need it per-user unique, but it can't be globally unique?
    Game Servers are the next hot market!
    Slim margins, heavy support, fickle customers, and moronic suppliers!
    Start your own today!

  3. #3
    Join Date
    Jul 2003
    If your database supports sequences, you can use those. If it doesn't use a DB class that has sequence support (like PEAR:B).
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts