I'm joining two tables (questions and choices) to get a result like this based on a ID called 'Q007'
SELECT c.code, c.label
FROM questions q, choices c
WHERE q.id = c.id
AND q.id = 'Q007'
Code Label
1 1
2 5
3 10
4 15
5 20
6 25
7 30
Now, I have a 'questiondata' table which have an 'id' as a column name. The rows contain the 'code' based on the 'choices' table.
SELECT qd.Q007
FROM questionsdata dq
Q007
1
2
6
1
2
6
6
1
5
7
2
Now, I want to list sometihng like, (Q007, label) that contains the two queries shown above. How would I do that? Should I use a subquery? Example, I want my output to look like:
Q007 label
1 1
2 5
6 25
1 1
2 5
6 25
6 25
1 1
5 20
7 30
Any ideas?