Welcome to WebmasterWorld Guest from 54.146.201.80

Forum Moderators: open

Message Too Old, No Replies

How do I add auto increment to the extra field

     
11:15 am on Jun 5, 2013 (gmt 0)

New User

5+ Year Member

joined:Nov 22, 2010
posts: 4
votes: 0


Hi

How do I ad auto_increment to the extra field so that it looks just like this?
[seamedia.in ]

I tried running a sql query:
SELECT * FROM `blog_posts` WHERE 1
ALTER TABLE `post_id` AUTO_INCREMENT

the error is:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE `post_id` AUTO_INCREMENT LIMIT 0, 30' at line 2

Thanks
11:53 pm on June 5, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2005
posts:1108
votes: 0


Why are you doing both a SELECT and an ALTER TABLE in one SQL expression,?

What you probably need is.

ALTER TABLE tbl_name CHANGE old_col_name new_col_name column_definition

e.g.

ALTER TABLE 'blog_posts' CHANGE 'post_id' 'post_id' int(11) AUTO_INCREMENT PRIMARY KEY;
8:48 am on June 6, 2013 (gmt 0)

New User

5+ Year Member

joined:Nov 22, 2010
posts: 4
votes: 0


I don't know why I was doing both SELECT and ALTER TABLE! I'm quite new to this.

I ran this sql query:
ALTER TABLE 'blog_posts' CHANGE 'post_id' 'post_id' int(11) AUTO_INCREMENT PRIMARY KEY;

but I'm getting this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blog_posts' CHANGE 'post_id' 'post_id' int(11) AUTO_INCREMENT PRIMARY KEY' at line 1

any ideas? Thanks for your help.
9:55 pm on June 6, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2005
posts:1108
votes: 0


Try it without any quotes.