Re: [PHP] Pragmatically changing a "Record Number"




On Aug 29, 2007, at 2:41 PM, Stephen wrote:

--- Jason Pruim <japruim@xxxxxxxxxx> wrote:

So to say it another way, I have a table that has
900 records in it,
I've added 3 records, but then deleted 2 of those
which puts the
actual record count at 901 but my auto increment
field starts at 904
on the next insert.

Is there away with PHP that I can pragmatically
change that value to
the total records in the database more so then a
representation of
the actual record number?

Some database concepts:

The autoincrement feature is to provide a unique "key"
for the record. It does not provide an "order". Many
tables have more than one "order".

Usually a different field or field determines the
order(s). It usually has an index.

To provide a row number, based on some order, you need
a field for this. Whenever a field is deleted, you
would need to repopulate the fields in each record
after the deleted record in the database.

Which is exactly what I am trying to figure out :) in excel this would be the same as clearing the info in a row and then sorting it to take out the blank lines :)


I saw a nested SQL query that did this once, but my
SQL is not good enough to try to illustrate.

I'll keep looking, I'm sure there is away to do it, but playing with the auto incrementing column may not be the best idea...

Stephen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruim@xxxxxxxxxx
.



Relevant Pages

  • Re: [PHP] Pragmatically changing a "Record Number"
    ... actual record count at 901 but my auto increment ... Some database concepts: ... I saw a nested SQL query that did this once, ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] Pragmatically changing a "Record Number"
    ... which puts the ... actual record count at 901 but my auto increment ... Some database concepts: ... I saw a nested SQL query that did this once, ...
    (php.general)
  • Re: help with perl dbi and update without locks
    ... If I understand correctly you want to auto increment a numeric primary key ... This is heavily dependent on the database you are using. ... Another common method is to use an insert trigger that calculates the next ...
    (comp.lang.perl.misc)
  • Re: [PHP] Pragmatically changing a "Record Number"
    ... So to say it another way, I have a table that has 900 records in it, I've added 3 records, but then deleted 2 of those which puts the actual record count at 901 but my auto increment field starts at 904 on the next insert. ... Is there away with PHP that I can pragmatically change that value to the total records in the database more so then a representation of the actual record number? ... I've seen many people who wished to "fix" sequences like this before, usually because they believe there is something "wrong" with there being gaps in there. ...
    (php.general)
  • Data Migration
    ... I'm trying to migrate data from an Access 2000 database to SQL 2005 Express. ... Most primary keys are Auto Increment fields. ... I'm having the issue that even if I set primary key manually in my code, the Auto Increment rules seem to override this. ... as it would corrupt the relationships of existing data when I read from Access and Write to SQL. ...
    (microsoft.public.dotnet.general)