Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts

    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

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,301
    Thanks
    4
    Thanked 204 Times in 201 Posts
    Code:
    ALTER TABLE `clients` ADD `new` char(1) NOT NULL default 'y' , ADD INDEX ( new)
    Dave .... HostMonster for all of your hosting needs

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Thanks for help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •