Question

I'm using MySQL as database for online examination system. here Question No. is primary key so, when a question in middle is deleted that number is wasted,(just like in queue data structure).I want the next question numbers to be automatically decremented. is it possible by using PHP and MySQL. If yes, then please write the solution.

Était-ce utile?

La solution

Please do not do this!

The number of the primary key has only one function: Uniquely identifying a record. It does not matter what number it is and if there are gaps in between.

If you want to sort your data use another column like a datetime column or an extra ranking index.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top