Q:

Why are variables being cut out? 

High school students trying to create a version of Facebook for our school.  Right now we are stuck on joining tables in the trial database before we can release it. 
To join the tables post, users, and friends:
users
user    name
1       Hallie  
2       Dylan
3       Sarina
4       Dominic

friends
user    friend
1       2
1       3
1       4
2       1
3       1
4       1
2       4
4       2
3       2
2       3

posts
| user | postid | post |
+------+--------+------+
|    1 |    101 |  This is TigerBook!           |
|    2 |    102 |  I am pregnant.               |
|    1 |    103 |  I like peeps                |
|    4 |    104 |  Giant Buzz Lightyears rock.  |
|    3 |    105 |  Die Tucker die              |
|    1 |    106 |  Murhur de derpity derp      |
|    2 |    107 |  banana spaghetti squid      |
|    4 |    108 |  chicken                     |
We used this code:
SELECT users.user, 
       users.name, 
       posts.postid, 
       posts.post, 
       tmp.friend 
FROM   (SELECT friend, 
               user 
        FROM   friends 
        GROUP  BY friend) AS tmp 
       JOIN users 
         ON tmp.user = users.user 
       JOIN posts 
         ON posts.user = users.user; 

And it comes up with the result of:
+------+---------+--------+-------------------------+--------+
| user | name    | postid | post                    | friend |
+------+---------+--------+-------------------------+--------+
|    1 |  Hallie |    101 |  This is TigerBook!      |      2 |
|    1 |  Hallie |    101 |  This is TigerBook!      |      3 |
|    1 |  Hallie |    101 |  This is TigerBook!      |      4 |
|    2 |  Dylan  |    102 |  I am pregnant.          |      1 |
|    1 |  Hallie |    103 |  I like peeps           |      2 |
|    1 |  Hallie |    103 |  I like peeps           |      3 |
|    1 |  Hallie |    103 |  I like peeps           |      4 |
|    1 |  Hallie |    106 |  Murhur de derpity derp |      2 |
|    1 |  Hallie |    106 |  Murhur de derpity derp |      3 |
|    1 |  Hallie |    106 |  Murhur de derpity derp |      4 |
|    2 |  Dylan  |    107 |  banana spaghetti squid |      1 |
+------+---------+--------+-------------------------+--------+
It cuts out posts 104, 105, and 108.  Which were posted by users 3 and 4.  And it ignores the fact that user 2 is friends with 3 and 4, as well as the 1 that it shows.  
Why is it not bringing up users 3 and 4?  Should we try a different code? 

A:

Look what your subquery returns:
| FRIEND | USER |
-----------------
|      1 |    2 |
|      2 |    1 |
|      3 |    1 |
|      4 |    1 |

Because of the GROUP BY, you lose multiple user values associated with friends. 
Why did you use a subquery instead of simply JOINing with the friends table itself? 
SELECT users.user,
   users.name,
   posts.postid,
   posts.post,
   friends.friend
FROM friends
   JOIN users
     ON friends.user = users.user
   JOIN posts
     ON posts.user = users.user;

| USER |    NAME | POSTID |                        POST | FRIEND |
------------------------------------------------------------------
|    1 |  Hallie |    101 |          This is TigerBook!  |      2 |
|    1 |  Hallie |    103 |                I like peeps |      2 |
|    1 |  Hallie |    106 |      Murhur de derpity derp |      2 |
|    1 |  Hallie |    101 |          This is TigerBook!  |      3 |
|    1 |  Hallie |    103 |                I like peeps |      3 |
|    1 |  Hallie |    106 |      Murhur de derpity derp |      3 |
|    1 |  Hallie |    101 |          This is TigerBook!  |      4 |
|    1 |  Hallie |    103 |                I like peeps |      4 |
|    1 |  Hallie |    106 |      Murhur de derpity derp |      4 |
|    2 |   Dylan |    102 |              I am pregnant.  |      1 |
|    2 |   Dylan |    107 |      banana spaghetti squid |      1 |
|    2 |   Dylan |    102 |              I am pregnant.  |      3 |
|    2 |   Dylan |    107 |      banana spaghetti squid |      3 |
|    2 |   Dylan |    102 |              I am pregnant.  |      4 |
|    2 |   Dylan |    107 |      banana spaghetti squid |      4 |
|    3 |  Sarina |    105 |              Die Tucker die |      1 |
|    3 |  Sarina |    105 |              Die Tucker die |      2 |
|    4 | Dominic |    104 | Giant Buzz Lightyears rock.  |      1 |
|    4 | Dominic |    108 |                     chicken |      1 |
|    4 | Dominic |    104 | Giant Buzz Lightyears rock.  |      2 |
|    4 | Dominic |    108 |                     chicken |      2 |

http://sqlfiddle.com/#!2/27eb3d/6

