title: SQL beginner - How do I retrieve the youngest patient that tested positive?
body: <p>I'm creating code that simulates patients going to the hospital to test for covid-19. I need to consult the youngest patient that tested positive (the patients only have different ages), but I can't get the information right about the patient (<code>patient_name</code>, <code>codepatient</code>). I've tried using subquery:</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT P.patient_name, P.patient_age, T.results
  FROM patient P
      LEFT OUTER JOIN testing T on T.codepatient=P.codepatient
  WHERE P.patient_age = 
        (SELECT min(P.patient_age)
        FROM patient P);
  </code></pre>
  <p>But I can't find a way to retrieve the testing = 'Positive'. I also tried this:</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT P.patient_name, min(P.patient_age), T.results, T.codepatient
  FROM patient P
    INNER JOIN testing T on T.codepatient=P.codepatient
  WHERE T.results = 'Positive';
  </code></pre>
  <p>Unfortunately it shows only the right age, the name and code are selected from the oldest patient.
  I'm a college student and I'm beginning to use MySQL. English is my second language, i'm trying my best to ask this question clearly, i apologize if i make mistakes.</p>