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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    274
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Moving a field up

    I have a column called alphabet, with the fields B, A, C, D:

    alphabet
    --------
    B
    A
    C
    D


    I am wanting to know how I can go about moving A up to where B is, so:

    Alphabet
    --------
    A
    B
    C
    D

    There are other fields from other columns on this same line:

    A | Active | Always


    This procedure would be similar to:
    ALTER TABLE (table) CHANGE COLUMN (column) (new column name) (type) AFTER (column);, but for a field instead of a column.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    no it wouldn't be similar to that at all, you would use an ORDER BY in your query.

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    274
    Thanks
    38
    Thanked 0 Times in 0 Posts
    Cool, so do you know how it can be done?

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,307
    Thanks
    4
    Thanked 205 Times in 202 Posts
    Code:
    SELECT something FROM table_name ORDER BY `alphabet`
    Dave .... HostMonster for all of your hosting needs

  • #5
    Regular Coder
    Join Date
    Sep 2011
    Posts
    274
    Thanks
    38
    Thanked 0 Times in 0 Posts
    Ah.. I am wanting to make it so they will be alphabetical when I select *.
    Last edited by FlashDance; 11-10-2011 at 05:15 PM.

  • #6
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,307
    Thanks
    4
    Thanked 205 Times in 202 Posts
    So change my something to * ... the order by is what will make the result set returned alphabetical.
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

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