Hello,
I have to queries that I use:
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.
var query = "SELECT Site FROM SiteReport WHERE Date <= '"+dt+"' AND 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.
DarilPosted Jan 21, 2022, 7:26 AM
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]
shay aPosted Dec 28, 2021, 12:27 PM
Sai Kumar KoonaPosted Dec 27, 2021, 6:36 PM