SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy cydewaze's Avatar
    Join Date
    Jan 2006
    Location
    Merry Land, USA
    Posts
    1,096
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Fetching column names from another table

    I've inherited an Access database that has sort of cryptic column names. The reason (I think) is because the actual column names that get displayed on the web page are long, and have quotes and parens in them, so whoever built the thing abbreviated the column names by using the first letter of each word.

    Anyway, since no one can remember which column is which, I added a table to the database that has a column for the names, and a column containing the descriptions, so whoever updates the thing can refer to that table to figure out which column is which.

    Right now, the column names are hard-coded on the web page, but I'd rather fetch them out of the database. The problem is, I don't know any way of joining a row in my table with a column name in the old table.

    Any ideas?

  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)
    why not create a view for the badly-named table? give each column a better name
    Code:
    SELECT sdurfgsd AS my_nice_name_for_column_1
         , ierjhwkc AS my_nice_name_for_column_2
         , netqsvyh AS my_nice_name_for_column_3
         , ...
      FROM daTable
    save this query, and then you can use it instead of the table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard bronze trophy cydewaze's Avatar
    Join Date
    Jan 2006
    Location
    Merry Land, USA
    Posts
    1,096
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Yep that would work. I was just shooting for a way to grab the column names out of the database, in case someday they decide to rename a column. The content owners have access to the database, but not the CF page. If the column names are stored in the db, they can change it anytime they want. If they're on the CF page, they have to get a web guy to change them.


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
  •