Skip to content
Advertisement

SQL query to combine the results from two tables

I have these two tables and I want to build a SQL query:

enter image description here

My search criteria is:

  • Name (in field Brother and field Speaker)
  • Congregation (in field Congregation in both tables)

I want the resulting view to be a single list of all records, sorted by date (fields Talk Date and Last Given).

So:

  • Away Talks

I am interesting in this info:

Talk Date, Talk Number, Congregation, Brother

  • Home Talks

Last Given, Talk Number, Congregation, Speaker

I would like to pull the above two sets of results into a single list sorted by the date column.

I started to do a SQL query in Access 2016 but am lost!

Advertisement

Answer

You can use union all:

select [Talk Date], [Talk Number], Congregation, Brother as Speaker
from [Away Talks]
union all
select [Last Given], [Talk Number], Congregation, Speaker
from [Home Talks]
order by [Talk Date]

  
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement