Hey guys, i have a table which has id(unique key) and data.. while displaying one record(row), i need to display the unique key(id) of next record..please help.
for this you can use auto increment id.. CREATE TABLE `yourneed` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR( 80 ) NOT NULL ) ENGINE = innodb; Here id is auto increment and also unique it never be duplicate.. You just have to insert value in only name field........
hi ajit, i understand that this could solve my problem. but i already have a huge database. do you want me to edit the table and add Id column?
This depends on what your problem is. Do you want to show the id of the next record already present in the table? Or do you want to show the id that would be used if you inserted a new record in the table? If you want to show the id of the next record already present in the table, an autoincrement field does not solve anything, unless you never ever delete any records.
Do you mean to say that in the page showing a record, you need to have a link which when clicked takes you to the next result??? This has nothing to do with auto-increment. There will always be a unique id for a record, it need not have to be a auto-increment. This can be done with some php coding. Even if you have a large DB, you can add a auto-increment field, if necessary. If you need any help you can PM me...
Yes it may be true, that in this case autoincrement id is not necessary, we can do it by getting a max row of entire table and incrrease it by 1 and insert this value........