Aggregating results of two database views in one database view I have a view with name of UserInfo like this:


  


And another view with name of UserRoleInfo like this:


  


I want to aggregate all the records of the two views for one user name like H.F into one view.


  


I tried to join the two views on user name but does not work!

How can I have all records of these two views in one view with the same columns as in picture 3?
You want to use the UNION ALL operator, rather than trying to JOIN on Username.

A UNION ALL returns a combination of all results from Query A and Query B.

Alternatively, if you only wanted DISTINCT records from the set, you could omit the ALL keyword and just do a UNION.

SELECT
    UserID,
    Username,
    OperationFaName,
    OperationEnName,
    ComponentName,
    AccessString,
    ApplicationName,
    ApplicationID
FROM UserInfo

UNION ALL

SELECT
    UserID,
    Username,
    OperationFaName,
    OperationEnName,
    ComponentName,
    AccessString,
    ApplicationName,
    ApplicationID
FROM UserRoleInfo