I have 2 tables:
Table1:
ID | Mobile Number | Name | Ordered Product| Order Date
Table2:
ID(foreign_key can be inserted multipletimes in this table) |Contacted_for | Time(timestamp)
I need a query to display all the data in Table1 and if the ID is present in Table 2, I need to display the last inserted record on Table2(with time) of that ID
My query is
select a.* , b.* FROM table1 a LEFT JOIN table2 b ON a.ID=b.ID GROUP BY a.ID ORDER BY b.Time DESC
Here in my query when I remove Group By a.ID, it works but shows all results. But I want to show final record of table2 only(no duplicate ID records)
Thanks in advance