By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,959 Members | 2,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,959 IT Pros & Developers. It's quick & easy.

Get value of a specific field from a set of fields

P: 90
I have a Table1:
Expand|Select|Wrap|Line Numbers
  1. ========================================
  2. ID    Opt1    Opt2      Opt3       Opt4
  3. ========================================
  4. 1     xxxx    yyyy      zzzzz      aaaaa
  5. 2     kkkkk   llllll    mmmmm      zzzzz
  6. 3     bbbbbb  cccccc    dddddd     eeeee
  7.  
  8.  
Another Table2:
Expand|Select|Wrap|Line Numbers
  1. ===========
  2. ID    Opts
  3. ===========
  4. 1     Opt2
  5. 2     Opt4
  6. 3     Opt1
  7.  
  8.  
I want a query to give:
Expand|Select|Wrap|Line Numbers
  1. =============
  2. ID    Values
  3. =============
  4. 1     yyyy
  5. 2     zzzzz
  6. 3     bbbbbb
  7.  
  8.  
or a combination:
Expand|Select|Wrap|Line Numbers
  1. ====================================================
  2. ID    Opt1    Opt2      Opt3       Opt4      Values
  3. ====================================================
  4. 1     xxxx    yyyy      zzzzz      aaaaa     yyyy
  5. 2     kkkkk   llllll    mmmmm      zzzzz     zzzzz
  6. 3     bbbbbb  cccccc    dddddd     eeeee     bbbbbb
  7.  
  8.  
Please note that the values of field ID from both tables are same.

Please help me. Thanking in anticipation.
Feb 22 '18 #1

✓ answered by gnawoncents

Try this as the SQL for your Query:
Expand|Select|Wrap|Line Numbers
  1. SELECT Table2.ID, DLookUp([Table2].[Opts],"Table1","[Table1].[ID] = " & [Table2].[ID]) AS [Values]
  2. FROM Table2;
  3.  

Share this Question
Share on Google+
3 Replies


gnawoncents
100+
P: 214
Try this as the SQL for your Query:
Expand|Select|Wrap|Line Numbers
  1. SELECT Table2.ID, DLookUp([Table2].[Opts],"Table1","[Table1].[ID] = " & [Table2].[ID]) AS [Values]
  2. FROM Table2;
  3.  
Feb 23 '18 #2

P: 90
Nice. It worked for me! Thank you.
Feb 23 '18 #3

gnawoncents
100+
P: 214
You are quite welcome!
Feb 24 '18 #4

Post your reply

Sign in to post your reply or Sign up for a free account.