After Hours



SQL Query

By gregg.veinpel ·
Tags: Off Topic
I am querying data that is housed in two tables.

The first table is a day of the week table
consisting of two columns as follows

ID Symbol
1 Sunday
2 Monday

The second table contains six columns
id Symbol Day1 Day2 Day3 Day4 Day5
1 order1 1 3 5 6 7

and so on

I want to be able to write a query that allows me to pull back the actual days of the week that are referenced in the columns day1, day2, day3, etc. while using a Where clause to select orders based on their symbol

so what i wnat from the query is

Order1 Sunday Tuesday Thurday Friday Saturday

Thanks, Gregg

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

There must be a better way, but....

by john.a.wills In reply to SQL Query

SELECT SecondTable.Symbol as Order1,
FROM SecondTable LEFT JOIN FirstTable d1
ON Day1 = d1.Symbol
LEFT JOIN FirstTable d2...
ON Day2 = d2.Symbol...

Related Discussions

Related Forums