I'm with a problem in table joining. I already search in google but not able to solve this problem. I wanted to get max 4 row in join table. I'm putting here my dummy table structure.
here is table `users`
--------------------
| id | name |
--------------------
| 1 | John |
--------------------
| 2 | Mohn |
--------------------
here is table `user_transections`
------------------------------------------------
| id | user_id | amount | created_at |
------------------------------------------------
| 1 | 1 | 20 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
| 2 | 1 | 30 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
| 3 | 1 | 50 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
| 4 | 1 | 60 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
| 5 | 2 | 10 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
| 6 | 2 | 15 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
| 7 | 2 | 80 | xxxx-xx-xx xx:xx:xx |
------------------------------------------------
I wanted to join only 3 row for each table match of users
SELECT user.name,user_transections.amount FROM users
INNER JOIN user_transections on user.id = user_transections.user_id
// how can i add limit here to join max three row of transections table