Add Columns Of Two Tables In A Single SQL Query

In this article I will demonstrate how to add columns of different tables into one column.
  • 2578

In this article I will demonstrate how to add columns of different tables into one column. This can be done by using single SQL query and no need to write insert query again and again.

Here I give an example to add columns of different tables into one column. We create two tables i.e Users and Users1 having one common column.

Users Table

UsersTable.jpg

Users1 Table

Users1Table.jpg

To add columns of both tables into one column, write following code snippet:

  select a.UserID as UserId, b.UserID as [UId], a.UserID + b.UserID as Addition

  from Users as a

  inner join Users1 b

  on a.UserName=b.UserName

Result

 AddTwoDifferentTableColumns.jpg

© 2020 DotNetHeaven. All rights reserved.