Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need to Recount Post ID column in table starting at 2000 instead of 1
Old 08-25-2004, 11:56 AM Need to Recount Post ID column in table starting at 2000 instead of 1
DKasler's Avatar
Skilled Talker

Posts: 83
Location: Brooklyn
Trades: 0
Need to Recount Post ID column in table starting at 2000 instead of 1

I'm working with another guy trying to merge two websites and our forums. I need to modify the posts id for one of the forums to prevent duplicate postid's. One forum has just over 2000 posts. The other has 450 posts. Is it even possible to recount the PID column so that it counts from 2001-2450 instead of 1-450?

Thanks in advance and let me know if you need more information.

Last edited by DKasler; 08-25-2004 at 11:59 AM..
DKasler is offline
Reply With Quote
View Public Profile Visit DKasler's homepage!
 
 
Register now for full access!
Old 08-25-2004, 12:14 PM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
try a select insert (assuming your trying to merge the tables)

something like

INSERT INTO TABLE (fld_1, fld_2, etc)
SELECT fld_1, fld_2, etc
FROM TABLE2 WHERE (whatever you need to do)

I would do this from the table with 450 in it. The ID should then become an increment of the table with 2000 entries so the first new entry will be 2001 methinks (cant be sure without testing it, but I think it should do the trick)

Always remember to let the database do the work, no good attempting complex formula when its probably built into your database.

if your not merging them try

ALTER TABLE (your table) AUTO_INCREMENT = 2000

will set the auto_increment to 2000

Ibbo
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 08-25-2004, 12:41 PM
DKasler's Avatar
Skilled Talker

Posts: 83
Location: Brooklyn
Trades: 0
Unfortunately the table is not auto incremented.

I need a line of code a that will add to the post id.

PID
1
2
3
4
5

etc and add 2000 to them say

PID
2001
2002
2003
etc
DKasler is offline
Reply With Quote
View Public Profile Visit DKasler's homepage!
 
Old 08-25-2004, 12:58 PM
DKasler's Avatar
Skilled Talker

Posts: 83
Location: Brooklyn
Trades: 0
Thanks. I found what I needed.

update yourtable set PID=PID+2000
DKasler is offline
Reply With Quote
View Public Profile Visit DKasler's homepage!
 
Reply     « Reply to Need to Recount Post ID column in table starting at 2000 instead of 1
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33093 seconds with 12 queries