title: mySql query - web file sharing program
body: <p>Here is my code. It is supposed to select the name of the person &quot;to_whom&quot; I'm sharing a particular file,
  and the whole thing needs to return back the user_id (u_c.to_whom) and the user_name,</p>
  <p>so I can populate my friends list with a checkboxe next to each other, that once clicked,
  will share (save into a DB table) that particular file to a specific person.</p>
  <p>This is from a web-app where users share files among each other.</p>
  <pre><code>SELECT u_c.to_whom, u.user_name
                      FROM files f
  
                      LEFT JOIN users_connections u_c
                      ON (u_c.who = :user_id OR u_c.to_whom = :user_id) AND u_c.friends = &quot;Y&quot;
                      
                      LEFT JOIN users u
                      ON u.user_id = u_c.to_whom
                      
                      WHERE f.file_id = 90
  </code></pre>
  <p>In the table <strong>files</strong> we have</p>
  <pre><code>file_id, file_name, file_desc, etc...
  </code></pre>
  <p>In the table <strong>users connections</strong></p>
  <pre><code>id, who, to_whom, friends
  1    1      4       Y
  </code></pre>
  <p>meaning that user 1 had initiated a friendship to user 4 and &quot;Y&quot; means the friendship is TRUE (N = still pending)</p>
  <p>And in <strong>users</strong> we have</p>
  <pre><code>user_id, user_name
     1       Jack
  </code></pre>
  <p>I cannot seem to get this working for some reason.
  Can any advanced user help me out?</p>
  <p>Thanks a bunch!!</p>