Trying to get a MySQL subquery to return multiple records
-
The following subquery returns 1024 records with a single count column. I am trying to return multiple columns with 1024 records. When I make changes to return multiple columns I get 17,000 records instead of 1024 records. I have very litle experience with subqueries. Does anyone have any suggestions? SELECT IFNULL(COUNT(DISTINCT A.computerid),0) AS 'Machine Count', A.hotfixID AS 'Last Contact' FROM (SELECT HF.computerid, HF.hotfixID FROM hotfixdata HFD INNER JOIN hotfix HF ON HF.hotfixid = HFD.hotfixid AND HFD.ignore <> 1 LEFT OUTER JOIN Computers AS C ON C.ComputerID=HF.ComputerID WHERE INSTR(C.os,"microsoft")>0 AND HF.installed <> 1 AND HF.Approved = 1 GROUP BY HF.hotfixID, HF.ComputerID) A;
-
The following subquery returns 1024 records with a single count column. I am trying to return multiple columns with 1024 records. When I make changes to return multiple columns I get 17,000 records instead of 1024 records. I have very litle experience with subqueries. Does anyone have any suggestions? SELECT IFNULL(COUNT(DISTINCT A.computerid),0) AS 'Machine Count', A.hotfixID AS 'Last Contact' FROM (SELECT HF.computerid, HF.hotfixID FROM hotfixdata HFD INNER JOIN hotfix HF ON HF.hotfixid = HFD.hotfixid AND HFD.ignore <> 1 LEFT OUTER JOIN Computers AS C ON C.ComputerID=HF.ComputerID WHERE INSTR(C.os,"microsoft")>0 AND HF.installed <> 1 AND HF.Approved = 1 GROUP BY HF.hotfixID, HF.ComputerID) A;