| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
|||
Querying the DatabaseHi all, new to all this. I am a final year student and i have a project to do. Basically i am doing a system based on a personal trainer site. I need to get this one query to pass basically, and i am suffering from a brain freeze!
I have a table called users, and in this table it contains alot of rubbish basically that wont be needed, but anyway there is a field called "planID" and its numbered 1-4 so when the user is joining up they select either 1,2,3 or 4 and this determines what routine they will be given. Anyway I have 4 other tables set up, called 1 2 3 and 4 and what i want to do is in the "View plan" section of my site, when they click on that, it looks at their username (using cookies on all "members area" pages), looks up the "users" table" then dumps out all the table info on the new screen which will make up their training plan. Any ideas? |
|
|||
|
One idea:
Code:
select u.username,
(case u.planID
when 1 then (select info from t1)
when 2 then (select info from t2)
when 3 then (select info from t3)
when 4 then (select info from t4)
end) as info
from users u
;
Dimitar |