Mysql join 3 tables by ID in R (How to get this query in R)

SELECT i.*, t.cause as tag_name
FROM users i
INNER JOIN donations tti ON (tti.uid = i.id)
INNER JOIN causes t ON (t.id = tti.causeId)

donations:

+--------------------+------------+   
|   uid   |  amount  |   date     |
+---------+----------+------------+
|    1    |    20    | 2013-10-10 | 
|    2    |    5     | 2013-10-03 | 
|    2    |    50    | 2013-09-25 |
|    2    |    5     | 2013-10-01 |
+---------+----------+------------+

users:

+----+------------+
| id |  username  | 
+----+------------+
| 1  |    rob     |
| 2  |    mike    | 
+----+------------+

causes:

+--------------------+------------+
|   id    |   uid    |   cause    | <missing cid (cause id)
+---------+----------+------------+
|    1    |    1     |  stop war  | 
|    2    |    2     |   love     | 
|    3    |    2     |   hate     | 
|    4    |    2     |   love     | 
+---------+----------+------------+

Result I want (data cropped for reading purposes)

+---------+-------------+---------+-------------+
|    id   |   username  | amount  |    cause    | 
+---------+-------------+---------+-------------+
|    1    |     rob     |   20    |  stop war   |
|    2    |     mike    |   5     |    love     |
+---------+-------------+-----------------------+

This is one way:
https://dplyr.tidyverse.org/reference/join.html

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.