SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Belfast, Northern Ireland
    0 Post(s)
    0 Thread(s)

    Question double primary/unique, how to autoincrement one based on the other.

    Sorry if the title of this post is a bit confusing as that what I am, confused.

    I have the following situation
    |EventID  |ComponentID | Description |
    |1        |1           | blah        |
    |1        |2           | de          |
    |2        |1           | blah        |
    I have a list of events which are broken into those generated by different components. The EventID is unique for each component (I have these generated as unique and primary).

    Now what I want to be able to do is add a new event, I want the page to display the number of the event being added (ie the next number in the autoincrement). This has to take into the account of the ComponentID, that is (based on the table above) if I were to add a Component 1 event it would have EventId 3 but if I were to add a Component 2 event it would have EventId 2..

    I'm not sure how to implement this as I'm a total Database novice.. if all else fails I'm tempted to have a table for each component but this would make adding new Components messy.

    Any help greatly appreciated.
    Last edited by kplex; May 20, 2002 at 13:48.


Posting Permissions

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