Question Locked

SQL Query

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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
etc.

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

2 replies

by john.a.wills

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

This discussion is closed to new replies.