Reply to Re: [PHP] Fixing ID's in mySQL Table

Your name:

Reply:


Posted by "Rahul S. Johari" on 10/20/49 11:31

Thanks!


On 11/8/05 11:49 AM, "Georgi Ivanov" <joro@abacustrade.com> wrote:

> You van do this :
> 1.Create new table with exactly the same structure as orig table.
> 2.Create little php script which does this :
> select * from origTBL
> while($line=mysql_fecth_array($res)){
> insert into newtbl values(............)
> }
>
> In the new tbl yuo will have the records ordered.
> Than just rename the tables.
>
> On Tuesday 08 November 2005 16:28, Rahul S. Johari wrote:
>> Ave,
>>
>> This is what I need to do.
>> Let's say, my ID's in a table look like this:
>>
>> 1
>> 7
>> 9
>> 11
>> 12
>> 19
>> 26
>> 27
>> 29
>> 30
>>
>> I need to alter the table so that the ID's are in a sequence like this:
>>
>> 1
>> 2
>> 3
>> 4
>> 5
>> 6
>> 7
>> 8
>> 9
>> 10
>>
>> It's easy to manually do this if you have a table with 10 records, but you
>> can't do it manually in a table with 5000 records.
>>
>> I know that I can DELETE the ID Column and recreate it and that will Fix
>> this problem, but doing that over and over with all the tables isn't what
>> I'm really looking for. I just feel there should be a way in PHP to execute
>> a logical query to do this. If not of course I can do the delete/recreate
>> using phpmyadmin, but I just want to see if there's a php script way to do
>> it.
>>
>> Thanks.
>>
>> On 11/8/05 9:22 AM, "Gustav Wiberg" <gustav@varupiraten.se> wrote:
>>> Hi there!
>>>
>>> Do you want an orderby-statement to be done on ID-field? Is that what you
>>> mean?
>>> I would go to phpmyadmin and fix that in the database-structure. (or some
>>> kind of database-utility)
>>>
>>> /G
>>> http://www.varupiraten.se/
>>>
>>>
>>>
>>> ----- Original Message -----
>>> From: "Rahul S. Johari" <rjohari@nycap.rr.com>
>>> To: "PHP" <php-general@lists.php.net>
>>> Sent: Tuesday, November 08, 2005 2:37 PM
>>> Subject: [PHP] Fixing ID's in mySQL Table
>>>
>>>
>>>
>>> Ave,
>>>
>>> Is there a way to fix ID sequence in a MySQL table using PHP?
>>> Basically I have some tables with a lot of records, 1000 to 5000. OID¹
>>> is the Primary Key column in these tables, and at the time the code was
>>> originally written, there weren¹t much verification of data being input
>>> going on. Thus a lot of junk records were being let in, which had to be
>>> deleted at some point or another. Now the ID sequence is all screwed up..
>>> It¹s not in sequence anymore.
>>>
>>> Is there a way to fix this?
>>>
>>> Thanks,
>>>
>>> Rahul S. Johari
>>> Coordinator, Internet & Administration
>>> Informed Marketing Services Inc.
>>> 251 River Street
>>> Troy, NY 12180
>>>
>>> Tel: (518) 266-0909 x154
>>> Fax: (518) 266-0909
>>>
>>>
>>> Email: rahul@informed-sources.com
>>> http://www.informed-sources.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Rahul S. Johari
Coordinator, Internet & Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180

Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: rahul@informed-sources.com
http://www.informed-sources.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация