Hello,
I have to queries that I use:
SQL
string query = "SELECT SiteListId.* FROM SiteListId LEFT JOIN SiteReport ON(SiteListId.Site = SiteReport.Site) WHERE SiteReport.Site IS NULL";the one above compering between 2 tables, SiteListId and SiteReport and the output is the differences.
C#
var query = "SELECT Site FROM SiteReport WHERE Date = '"+NewDate+"'";the above is pulling values from table SiteReport between 2 dates.
my question is:
is there a way to combine the queries?
i need to pull the info from SitePort between the dates and compare it with ListId for difference.
thank you,
Shay.

Daril148 reputationPosted Jan 21, 2022, 2:26 AM EST
To combine rows from two or more queries into a single result set, you can consider UNION operator.
The Union and Union all returns a single result set by combining rows from result sets. Union does not gives repeating rows but union all does gives repeating rows
Before entering a query using union you should make sure that The number of columns in all queries must be the same.
Example
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]
UNION
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]
Sai Kumar KoonaRank #334 · 7.5K reputationPosted Dec 27, 2021, 1:36 PM EST
shay a77 reputationPosted Dec 28, 2021, 7:27 AM EST