SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL Table Subheaders

    I think I've pretty much got the hang of creating MySQL tables. Now I'm just trying to refine my technique.

    The table I'm working on features all the world's nations, in about 250 rows. For display purposes, I added the names of the continents in additional rows. For example:

    NORTH AMERICA
    Canada
    United States
    Mexico
    South AMERICIA
    Brazil
    Venezuela

    It works fine, but when I sort a column, I'd prefer to isolate the subheaders (NORTH AMERICA, SOUTH AMERICA), so that they cluster at the top or the bottom, leaving a list of alphabetized nations only. Can this be done?

    I also wondered if it's possible to make the subheaders span several columns, so that they can be centered in the middle of the table, rather than stuck in the first or second column. However, I presume that can't be done without disrupting the sort function.

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,338
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you will need to separate the following concepts: structure and style

    you data is structured like this:

    NORTH AMERICA Canada
    NORTH AMERICA United States
    NORTH AMERICA Mexico
    SOUTH AMERICA Brazil
    SOUTH AMERICA Venezuela

    you might not have stored the continent names redundantly like that, but that's not the point, because that is exactly what you get as a result of a join query

    do not attempt to style the output using sql to look like this:

    NORTH AMERICA
    . Canada
    . United States
    . Mexico
    SOUTH AMERICA
    . Brazil
    . Venezuela

    that is best done in a programming language
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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