I have two table one contains the user information while other contains the user's device token and device type etc.
tbl_user
+----+----------+-----------+
| id | username | is_active |
+----+----------+-----------+
| 15 | UserA | 1 |
| 62 | UserB | 1 |
+----+----------+------------
tbl_user_token
+----------+---------+--------------+
| table_id | user_id | device_token |
+----------+---------+--------------+
| 1 | 15 | XXXXXXXXX |
| 2 | 15 | XXXXXXXXX |
| 3 | 15 | XXXXXXXXX |
| 4 | 62 | XXXXXXXXX |
| 5 | 62 | XXXXXXXXX |
| 6 | 62 | XXXXXXXXX |
+----------+---------+--------------+
So now i want to fetch the latest record from tbl_user_token in above case it should be
+---+----+-----------+
| 3 | 15 | XXXXXXXXX |
| 6 | 62 | XXXXXXXXX |
+---+----+-----------+
So far i have done below:
SELECT * FROM tbl_user tu
join tbl_user_token tut
on tut.user_id = tu.id
where tu.id in (15,62) and tu.is_active=1
group by tut.user_id
But it does not fetch the latest record.
Note: My question is different then the suggested question because answers on that question focus on how to fetch max value records from single table. But there is no information about what to do if need to use join with another table and find latest records.
I have to add criteria in other table (i.e. with tbl_user) table.