#1
  1. No Profile Picture
    chinnavi
    Guest
    Devshed Newbie (0 - 499 posts)
    hai
    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?

    vijay
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    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.

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    You can drop the id column & add the column again ... this will reindex the table

Similar Threads

  1. Mysql problem.
    By Nik in forum MySQL Help
    Replies: 54
    Last Post: December 21st, 2006, 06:02 PM
  2. Upgrade from access to mysql
    By karib1 in forum ASP Programming
    Replies: 7
    Last Post: December 16th, 2003, 12:35 PM
  3. Upgrade from access to mysql
    By karib1 in forum MySQL Help
    Replies: 1
    Last Post: December 16th, 2003, 12:27 AM
  4. problem: asp files, from access to mysql
    By karib1 in forum MySQL Help
    Replies: 1
    Last Post: November 26th, 2003, 03:16 AM

IMN logo majestic logo threadwatch logo seochat tools logo