php - How do you JOIN in SQL when you need the result of the query as a parameter? -


I am currently doing a query and then another query is running within that time when I know that Poor Practice I know that I need to be connected in some way, but to be a part of the external question I need the result of internal question and I am not sure how to do it.

  $ department = $ db- & gt; Prepare ("Select * FROM Dosage"); $ Departments- & gt; Executed (); While ($ line = $ section-> get (PDF :: FETCH_ASSOC)) {$ department_id = $ row ['department_id']; $ Total_problems = $ db- & gt; Prepare ("Select COUNT (*)` from the problems where the department = $ department_id "); $ Total_problems- & gt; Executed (); $ Depart_problems = $ total_problems- & gt; Fetch column (0); }   

I have tried to connect a lot but I can not find my head properly around it.

You are searching for a group query and a left External Participant :

  SELECT d.department_id, DDPPIDAD by DPPATADG Group in departments related to counts (PDEPMENT_ID);   

left external participant is important so that you get all the departments, even if they have problems or not.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -