Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Thanked 0 Times in 0 Posts

    [Oracle] I want my query to return a column name(s)

    I have a table that details when people would like to be called by our system. There are 15 columns, ID, MondayStart, MondayEnd, TuesdayStart, TuesdayEnd, etc. through Sunday. If a person prefers not to be called on any given day, the value entered is 00:00. Otherwise, the value entered is a military time.

    Is it possible for me to query this table and have it return to me only the column names and times for the times that are not 00:00? I would only ever query for one ID at a time. The ID is a primary key, so I would never be looking at more than one row at a time.

    I would want my result to look like this:

    ColumnName | Time
    MondayStart | 10:00
    MondayEnd | 12:00
    ThursdayStart | 13:30
    ThursdayEnd | 15:00

    I'm currently querying the table in a loop (checking each column one at a time for a value) and I'd like something quicker and cleaner if possible.

    It's okay if it can't be done. I just figured it couldn't hurt to ask.



  • #2
    Regular Coder
    Join Date
    May 2006
    Thanked 1 Time in 1 Post
    This can be done using UNION.


    Posting Permissions

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