Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Trying to get a MySQL subquery to return multiple records

Trying to get a MySQL subquery to return multiple records

Scheduled Pinned Locked Moved Database
mysqlquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SQL Ed
    wrote on last edited by
    #1

    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;

    L 1 Reply Last reply
    0
    • S SQL Ed

      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;

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Yup[^] :)

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups