If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Semi-complicated query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-26-04, 12:47
doctor doctor is offline
Registered User
 
Join Date: Jun 2004
Posts: 20
Hey everyone, hope your weekend was relaxing.

I need a to make a query that does the following, but first here are the objects w/ their relevant column names

My_Query
Current_ID

Table: Key

ID
Name


What i need to do is take the first Current_ID in My_Query, and use it to get the corresponding Name value from Key

If you have any questions as to what im trying to do or if this is not clear please let me know.

Thanks
Doc

Last edited by doctor; 07-26-04 at 14:56.
Reply With Quote
  #2 (permalink)  
Old 07-26-04, 13:21
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
In SQL Syntax, you want something like:
Code:
SELECT q.*, k.name
   FROM myQuery AS q
   JOIN key AS k
      ON (k.ID = q.Current_ID)
-PatP
Reply With Quote
  #3 (permalink)  
Old 07-26-04, 13:23
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool

Looks simple, is this part of your HOMEWORK?

You should try coding the solution yourself, that's the idea of homework.

Also check this out:

http://www.catb.org/~esr/faqs/smart-questions.html

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #4 (permalink)  
Old 07-26-04, 14:01
doctor doctor is offline
Registered User
 
Join Date: Jun 2004
Posts: 20
LKBrwn, No this is not part of my HOMEWORK (who has homework in the summer time anyway?) its just somthing im trying to do. Im trying to learn sql but dont really have any books or really good web references(just so-so) ones. So once in a while if im trying to do somthing i get stuck on i pop up on the boards. I wasnt looking for a complete solution, the hint provided was good enough to get me started, if i get lost ill bb. Instead of pointing me to a link on "smart question" how bout you point me to a link that has a good SQL rundown? Cause remember there are no stupid questions, only stupid people
Reply With Quote
  #5 (permalink)  
Old 07-26-04, 14:56
doctor doctor is offline
Registered User
 
Join Date: Jun 2004
Posts: 20
Ok, got my resultant list of data, last question is this: When it joins the data it auto orders the list via number. And for my purposes I need it in the order they appear in "my query". That i am really not sure how to do, my original post was quite trivial, sorry for posting a stupid question with a mislabelled subject.
Reply With Quote
  #6 (permalink)  
Old 07-26-04, 16:18
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Remove the ORDER BY from the existing query, and put that ORDER BY into the new SELECT statement that does the JOIN to the key table.

-PatP
Reply With Quote
  #7 (permalink)  
Old 07-26-04, 17:08
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #8 (permalink)  
Old 07-27-04, 09:31
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool

Quote:
Originally Posted by doctor
Cause remember there are no stupid questions, only stupid people
WE never intend to call anybody stupid for asking questions, in fact the purpose of all forum participants is to help/teach others how to solve a problem, "ask a good question, receive a good answer".

Also, when you post the code you are working on we know you have at least tried. When learning (in class or otherwise) it helps you most when you try to solve it by yourself and if you get stuck, then request some help.

Everybody here learns from each other, sometimes just looking at the solutions posted.

I wish you luck with your learning experience!
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #9 (permalink)  
Old 07-27-04, 12:37
doctor doctor is offline
Registered User
 
Join Date: Jun 2004
Posts: 20
Thank you very much, I appreciate it. I know what you mean bout the stupid people part i was just poking some fun at myself :-P

Thanks again
Doc
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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