Janos
Janos

Reputation: 13

vlookup functionality in Access

Deal all,

I am trying to create a query that creates a table after a criteria from another table (same as vlookup in excel) so I want to list in the same order matching another field's entries.

I was able to do that with one entry, but cannot for a whole field.

Any hints ?

Best, Janos

Upvotes: 1

Views: 244

Answers (1)

tyg
tyg

Reputation: 14902

What you need is a LEFT JOIN:

   SELECT *
     FROM table1
LEFT JOIN table2
       ON table1.reference_field = table2.reference_field

Adjust to your table and field names. Also see the documentation: https://msdn.microsoft.com/en-us/library/office/ff198084.aspx

Databases return entries in an arbitrary order if you do not explicitly define one. You can easily do so by appending this to your query:

 ORDER BY table1.reference_field

Again, adjust names to your liking. How you can order in descending order and how you can order by multiple fields is described in the documentation: https://msdn.microsoft.com/en-us/library/bb208913.aspx

Upvotes: 2

Related Questions