7
votes

I have a two tables similar to the following:

enter image description here

enter image description here

I am attempting to create a query in Access to create a table like this:

enter image description here

The crux of course is that the JOIN must match against both the Date and Name fields. I can join the fields from T2 into T1.

What is the proper syntax (either in SQL or via the query designer) to join the fields on both Date and Name?

My attempts have duplicated the field count.

2
The tables are an example. I do not use reserved words for field names. - Jason Strimpel

2 Answers

5
votes

Using the query design window, drag Date from T1 to match Date in T2 and similarly, drag Name from T1 to T2. This will give you an INNER JOIN on bioth name and date. Switch to SQL view to view the SQL.

BTW, both Name and Date are reserved words. Name in particular is a terrible thing to call anything in MS Access, so I hope these are imaginary field (column) names.

3
votes

sql is

Select T1.Name, T1.Date,T1.Alpha, T2.Beta
From T1
Inner Join T2 On T1.Name = T2.Name and T1.Date = T2.Date

And stop with the reserved words for object names...