Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a fieldname in the result of a query

Status
Not open for further replies.

frontside

Technical User
Sep 26, 2002
85
SE
I did a booking system using a bookingtable that looks like this

Date
time0700
time0800
time0900
time1000

day time0700 time0800 time0900 time1000
20050110 750712 780523 670914 870210

I´m putting the personID in the field of the date and time. That works just fine but the trouble is when I try to do a query that list all the dates and the time a certain personID has been booked! (There´s no problem getting the day with all the bookings but how do I get the day and only the field thats equal to the personID that i want.)

In the example above the result i would want for personID 780523 would be
Day Time
20050110 Time0800

I´m glad for any suggestions and help
 
You may consider a normalization union query saved as, say, qryPersonID:
SELECT [Date] As [Day], "Time0700" As [Time], time0700 As personID FROM bookingtable WHERE time0700 Is Not Null
UNION SELECT [Date], "Time0800", time0800 FROM bookingtable WHERE time0800 Is Not Null
UNION SELECT [Date], "Time0900", time0900 FROM bookingtable WHERE time0900 Is Not Null
UNION SELECT [Date], "Time1000", time1000 FROM bookingtable WHERE time1000 Is Not Null
;
And then you can try something like this:
SELECT [Day], [Time] FROM qryPersonID WHERE personID = 780523;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top