Get the latest record

mysql
sql

(Akhil Namburi) #1

I have 2 tables, second table contains the log details like updated_by,updated_date,id. I would like to join the 2 tables based on the id and the result table should contain the latest record of table2 and no duplicate values. I have tried the following query…

"select t.*,t.created_on::date, tl.updated_by ,tl.updated_date::date as updated_ts_date from test_name t join test_status_log tl on t.id =tl.id order by updated_date desc

for the above query I’m getting duplicate rows of table2, if I place “desc limit 1” the i’m getting only 1 record where it should return 250+ records.