Dipesh Parmar
Dipesh Parmar

Reputation: 27382

having really strange issue in auto_increment

I have table called notifications and i have id auto_increment primary key.

Complete Table Structure.

CREATE TABLE IF NOT EXISTS `notifications` (
  `id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `sender_picture` varchar(300) NOT NULL,
  `title` varchar(300) NOT NULL,
  `message_link` varchar(500) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `status` tinyint(4) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Now problem is that auto_increment should insert record as below.

1 record
2 record
3 record

But its really strange why my phpmyadmin show me record as below.

1 record
3 record
2 record

Is there any options do i need to set in phpmyadmin.

Thank You.

Upvotes: 3

Views: 56

Answers (2)

John Woo
John Woo

Reputation: 263883

Actually it is not a problem. Leave the records as is because those records are inserted randomly on the table.

Just do the ordering you desired during the projection (SELECT statement). eg,

SELECT * 
FROM   TABLENAME 
ORDER  BY colName ASC // or DESC for descending

The clients will not look on the database but on the application you created :D

Upvotes: 2

Sharon Haim Pour
Sharon Haim Pour

Reputation: 6723

Sometimes the phpmyadmin sorts the records by another field for display.

Upvotes: 0

Related Questions