Welcome to WebmasterWorld Guest from 54.159.214.250

Forum Moderators: open

How do I add auto increment to the extra field

   
11:15 am on Jun 5, 2013 (gmt 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 Jun 5, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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 Jun 6, 2013 (gmt 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 Jun 6, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Try it without any quotes.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month