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 > Database Server Software > MySQL > Substitute value of one field with value from another one ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-10-04, 10:06
jorgen180 jorgen180 is offline
Registered User
 
Join Date: Mar 2004
Posts: 3
Question Substitute value of one field with value from another one ?

Hi, everyone.


If I have a Table 1 with these fields:



Name | Surname | Function


record sample:


Joe | Blow | 430


...and Table 2 with two fields, first one having IDs of Table 1's "Function" field and second one with their description:


ID | Description


record sample:


430 | IT manager



How would I do queries on Table 1 to pull out description from Table 2 instead of ID value of "Function" field in Table 1 ? In other words, I need to substitute ID codes from Table 1 with Descriptions from Table 2, making a kind of relational queries.


I know there's a way of using query inside another query, but have no idea how to get current record's field and pull other table's substitution instead of it, all in one query.


Thank you for all suggestions !
Reply With Quote
  #2 (permalink)  
Old 04-14-04, 12:10
Wigz Wigz is offline
Registered User
 
Join Date: Feb 2003
Location: Denver, CO
Posts: 34
I didn't test this, but it's something like this example using a simple join:

SELECT table1.Name, table1.Surname, table2.Description FROM table1, table2 WHERE table1.Function = table2.ID
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