I’ve got two different SQL queries that I need to run at once. But since I am using inner joins in both of them, I can’t just join them. Is there a way to do this? Also, do you think that much normalization could cause problems?
SELECT S.SchoolName,Sd.DepartmentName,E.GraduationDate
FROM Education E
INNER JOIN SchoolDepartment Sd ON Sd.DepartmentID = E.DepartmentID
JOIN School S ON S.SchoolID = Sd.SchoolID
SELECT c.CompanyName,dt.DepartmentName, pl.PositionLevelName
FROM Employee Ee
INNER JOIN Position P ON Ee.PositionID = P.PositionID
JOIN Company c ON c.CompanyID = P.CompanyID
JOIN Department De ON De.DepartmentID=P.DepartmentID
JOIN DepartmentType dt ON dt.DepartmentName = De.DepartmentTypeID
JOIN PositionLevel pl ON pl.PositionLevelID=P.PositionLevelID
You haven’t indicated how they both are connected to a profile and whether each set is going to have many rows which are unrelated to each other. If each just returns a single row and both are related to the profile (related in the sense of relational database – attributes “related” to a key – perhaps your profile), there there probably is a realistic way to combine them into a single result set (i.e. a relation, or table).
There are a few strategies you can use if the sets on not really related in that sense.
Make a single stored procedure or batch both in the same command which returns both result sets in sequence and use ADO.NET’s feature to get the next result set on your reader.
Make two sequential calls to the database.
Use ASP and ADO’s asynchronous features to make two simultaneous calls to the database and handle the completions – this can be useful for high-volume sites, since control is returned to the page once they are completed, freeing up threads.