1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Database

Discussion in 'PHP' started by santoshshinde, Jul 26, 2008.

  1. #1
    In a database table we can't give two auto-increments. But i have a requirement in which another auto-increment is required.So please give me a suggestion how to get another auto-increment.
     
    santoshshinde, Jul 26, 2008 IP
  2. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can't use two auto-increments in the same table because it causes conflicts. Why not create another table and use JOIN/JOIN LEFT/JOIN RIGHT etc etc. Or you can write in the PHP code to increase ++$value in your selected column everytime the method happens
     
    Mozzart, Jul 26, 2008 IP
  3. Submerged

    Submerged Active Member

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    You could also do a two step process with only one of them being auto-correct. Basically, create the record how you normally would (with the first auto-increment NULL). Then search for that entry (that you just entered) and get the value of the auto-increment. Then update that record to make the second auto-increment equal to that value.

    Bit annoying, but it would work. You could also keep a running total of the high auto-increment to reference and just base the second auto-increment on that.
     
    Submerged, Jul 26, 2008 IP