Selecting a id from a pivot table Trying to make a messaging system, similar to FB, people can message more than one person, when they do it creates a row for the user with the conversation id and user_id in conversation_user. 

create table conversations(
  id int
);
create table users(
  id int,
  name text
);
create table conversations_users(
  user_id int,
  conversation_id int
);
create table conversations_reply(
  id int,
  user_id int,
  body text,
  conversation_id int
);


I want to select the last 10 conversation that user_id 1 is a participant in and select the last post of that conversation. How would I go about doing this?

http://sqlfiddle.com/#!9/eb0075
We can find with subquery each conversation_id for user_id from table conversations_users and use left join for get one reply for each conversation_id from conversation_reply table (see sqlfiddle example and code below)

select cp1.* from conversations_reply cp1 
left join conversations_reply cp2 
  on (cp1.conversation_id = cp2.conversation_id AND cp1.id &lt; cp2.id)
where cp2.id is NULL and
  cp1.conversation_id in (
    select conversation_id from conversations_users where user_id = 4
  ) 
order by cp1.id desc limit 10;


Output will be

+---+-------+--------+---------------+
|id |user_id|body    |conversation_id|
+---+-------+--------+---------------+
|9  |      4| message|              4|
|8  |      4| message|              3|
|7  |      1| message|              1|
|6  |      4| message|              2|
+---+-------+--------+---------------+