Join 3 tables returns too many results I have 3 tables: users, posts, videos. The last 2 tables have user_id that associate with users.id (first table).

The problem is that when I try to run inner join query and return all posts and videos that have user_id and exists in both tables, I get multiple same records.

select * from `users`   
inner join `videos` on `users`.`id` = `videos`.`user_id`   
inner join `posts` on `users`.`id` = `posts`.`user_id`   
where `users`.`id` = ?   
limit 50 offset 0  


If I run the queries separately, I get 6 rows and 8 rows but with the join I get 48 rows.
If you want 14 rows in the result (6+8), you need to use UNION of the two queries you already have.  Just take care for both to have the same number of columns (and same datatypes in the respective columns.) 

It will be something like:

SELECT u.*,                              -- list of wanted columns from the users table
       'Video'     AS type
       v.id        AS item_id,           -- and the videos table
       v.posted_at AS posted_datetime  
FROM users AS u 
  INNER JOIN videos AS v 
    ON u.id = v.user_id
WHERE u.id = ?  

UNION ALL

SELECT u.*, 
       'Post'      AS type
       p.id        AS item_id,           -- and the posts table
       p.posted_at AS posted_datetime  
FROM users AS u 
  INNER JOIN posts AS p 
    ON u.id = p.user_id
WHERE u.id = ?

ORDER BY posted_datetime                 -- ORDER BY some_column
LIMIT 50 OFFSET 0 ;