SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 04-21-2008, 11:30 AM
leehenchoz leehenchoz is offline
Junior Member
 
Join Date: Apr 2008
Posts: 1
leehenchoz is on a distinguished road
Default ANY dialect question:

Querying the Database


Hi 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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 04-21-2008, 07:54 PM
Dimitar
 
Posts: n/a
Default ANY answer. Re: Querying the Database

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
;
Hope this helps,
Dimitar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:50 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8