title: SQL join concat two different values
body: <p>I'm still in the process of learning SQL queries. I've tried searching around online, but I don't even know what terms I should be searching for, so I'm looking for someone to point me in the right direction. I have two tables -- appointments and logins. I'm trying to use the concat function to get the first and last name for both "apptFor" and "addedBy." Do I need to have separate queries? It seems like it should be able to get done in a single query.</p>
  
  <pre><code>&lt;table border="1"&gt;
     &lt;tbody&gt;
       &lt;tr&gt;
         &lt;td width="140" align="center"&gt;&lt;strong&gt;Appt Date/Time&lt;/strong&gt;&lt;/td&gt;
         &lt;td width="100" align="center"&gt;&lt;strong&gt;Appt For&lt;/strong&gt;&lt;/td&gt;
         &lt;td width="300" align="center"&gt;&lt;strong&gt;Appointment&lt;/strong&gt;&lt;/td&gt;
         &lt;td width="100" align="center"&gt;&lt;strong&gt;Added By&lt;/strong&gt;&lt;/td&gt;
         &lt;td width="100" align="center"&gt;&lt;strong&gt;Date Added&lt;/strong&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;?php
              $query = "SELECT a.appID,a.appDate,a.appNote,a.apptFor,a.addedBy,a.added,concat(u.firstName,' ',u.lastName) as appAddedBy FROM appointments a ";
              $query .=" INNER JOIN logins u on a.addedBy=u.userid WHERE a.userID='$uid' order by appDate asc";
              $result = mysqli_query($con, $query);
          if(mysqli_num_rows($result) &gt; 0)
          {
              while($row = mysqli_fetch_assoc($result))
              {
      ?&gt;
       &lt;tr&gt;
         &lt;td&gt;&lt;?php echo $row['appDate']; ?&gt;&lt;/td&gt;
         &lt;td&gt;&lt;?php echo $row['apptFor']; ?&gt;&lt;/td&gt;
         &lt;td&gt;&lt;?php echo $row['appNote']; ?&gt;&lt;/td&gt;
         &lt;td&gt;&lt;?php echo $row['appAddedBy']; ?&gt;&lt;/td&gt;
         &lt;td&gt;&lt;?php echo $row['added']; ?&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;?php  }} ?&gt;
     &lt;/tbody&gt;
   &lt;/table&gt;
  </code></pre>