title: PHP & SQL: Query for a name using join
body: <p>I've come across an issue where my one query in PHP for my mySQL database is not returning anything. The query works when using the mySQL database, and I'm assuming in my php file, but does not print out anything, and returns as a false value. Any help or tips/tricks you can give me is appreciated, I haven't actively used SQL in about a year, and I'm trying to learn as much PHP as possible in a very limited amount of time, so my syntax is probably not correct. I know my database is connected.</p>
  
  <p>The following code works further up in the program. </p>
  
  <pre><code>  $patIDQuery=("SELECT ID FROM patients WHERE usernam3='$myusername'");
    $patientID=mysqli_query($db, $patIDQuery);
    $row=mysqli_fetch_assoc($patientID);
    $user = $row['ID'];
    $_SESSION['myUserID']=$user;
  </code></pre>
  
  <p>In mySQL, this code works, and I am trying to get the same result. </p>
  
  <pre><code>SELECT medications.CLINNAME FROM medications RIGHT JOIN patientData ON patientData.medID=medications.medID WHERE patientData.ID='*the actual patient id*';
  </code></pre>
  
  <p>Code with an issue</p>
  
  <pre><code>&lt;?php
          $clinNameQ=("SELECT * FROM medications RIGHT JOIN patientData ON 'patientData.medID'='medications.medID' WHERE patientData.ID='$user'");
          $clinName=mysqli_query($db,$clinNameQ);
          $rowClin=mysqli_fetch_assoc($clinName);
          $clinicalName=$rowClin['CLINNAME'];
          echo $clinicalName;
   ?&gt;
  </code></pre>
  
  <p>I've been messing around with '' and "", but nothing seems to have been working. I'm wondering if there is an issue with backslashing, or if it is (what I think it is), an issue with the fetch.</p>
  
  <p>Help is so much appreciated!</p>