November 2nd, 2000, 09:57 AM
i have a problem in mysql.
i designed a Table in mysql with a column
id AUTO_INCREMENT PRIMARY KEY
My Problem now is whenever i delete any records in mysql , the problem arise.
Because i am getting the final value for my data counts ...
How can i reindex my table entries into an
ordered way after i deleted a record in between?
November 2nd, 2000, 09:53 PM
You need to rethink how you do your sql queries. If you want the total number of items in your table, don't select the highest id number, because, like you said, some of them could of been deleted. instead, use this:
select count(*) as num_items from your_table;
That'll return the number of non-null rows in the table.
SQL was designed to be able to put things in and take them out at any time. You design your queries around this using the function, group by, order by, etc, to return what you want no matter what order the data is stored in.
November 3rd, 2000, 09:43 AM
You can drop the id column & add the column again ... this will reindex the table