Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-15-2009, 03:16 PM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,512
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
How do I add an index when adding a new field?

Hi,

I would like to add an index as well as the new field.

I tried this, but it failed:

PHP Code:
$sql "ALTER TABLE `clients` ADD `new` char(1) NOT NULL default 'y',
 KEY `new` (`new`)"
;

 
$result mysql_query($sql)
    or die(
"could not ALTER clients."mysql_error()); 
Can anyone please help me get it right?
Thanks
jeddi is offline   Reply With Quote
Old 03-15-2009, 03:44 PM   PM User | #2
djm0219
Senior Coder

 
djm0219's Avatar
 
Join Date: Aug 2003
Location: Wake Forest, North Carolina
Posts: 1,227
Thanks: 2
Thanked 189 Times in 187 Posts
djm0219 is on a distinguished road
Code:
ALTER TABLE `clients` ADD `new` char(1) NOT NULL default 'y' , ADD INDEX ( new)
__________________
Dave .... HostMonster for all of your hosting needs
djm0219 is offline   Reply With Quote
Old 03-15-2009, 04:40 PM   PM User | #3
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,512
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Thanks for help
jeddi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 06:27 AM.


Advertisement
Log in to turn off these ads.