homepage Welcome to WebmasterWorld Guest from 54.242.231.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
How do I add auto increment to the extra field
Dgriff




msg:4581254
 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

 

Dijkgraaf




msg:4581510
 11:53 pm on Jun 5, 2013 (gmt 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;

Dgriff




msg:4581597
 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.

Dijkgraaf




msg:4581899
 9:55 pm on Jun 6, 2013 (gmt 0)

Try it without any quotes.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved