When you are using MS Access SQL, sometimes you need to combine two queries or tables. Suppose that you are creating separate tables for each month salary or any other record. Now you want to see across the entire time period. You can also create a new table consisting of the record of all these tables, but sometimes it is not very useful or desirable. We recommend you to use MS access SQL to join or combine these tables or queries. This article will tell you about how to use MS Access SQL to combine two tables or queries.
MS Access SQL is one of the relation database management tools designed by Microsoft. Previously it was known as MS access only. This is one of the most popular database managers present today. The working of this tool is very simple: it store data, then analyze and update the data. Microsoft Access SQL simplifies the queries given by you and updates those queries.
Steps to use MS Access SQL to combine two tables:
The very first step is to create a new query and go to SQL view. Now you have to type some SQL commands like select* from, now press enter.
After typing the SQL command, type union all and press enter.
Now you will type select*from to give the name of second table or query. Now these steps are done, repeat step 2 and 3.
Now you just have to run these queries, if you want to filter these queries then you have to save these queries. You can also use JOIN command to retrieve multiple tables. There can be several types of join like inner join, outer join, left join, right join. It works same as UNION statement.
JOIN is also very useful in retrieving data from multiple tables. JOIN statement also improves performance of the data base server. If you are using union all, it will return all the resources. If you do not want to return all the resources just use UNION. We recommend you to keep the square bracket in each SELECT statement. Sometimes the numbers of columns are not identical so you have to use field names like SELECT [field 1][field 5]. We recommended you to use union rather than union all command, because it is helpful when the returned columns from the different tables do not have columns or data that can be compared or joined. It also stop running multiple queries and appending the results in the application code. May be sometime your column name do not match while using UNION statement, then you should use aliases to give a meaningful result. UNION statement is very useful for occasional use but when you will use it frequently it will apply a heavy load on the database server.