How Do I Insert Only Recently Updated Row From Table1 To 2 in MySQL
-
i have two tables with same schema. i have to check table1 for any updates and insert the updates or the entire row into table2, only the most recently updated row.
so basically, table2 has the unique values from table1; for the duplicate entries in table1, there is only the most recent entry in table2.
i have tried to get the most recently updated id from table1:SELECT distinct id
FROM table1 order by time_date desc limit 1;now i need to use this id to get the other columns from table1 and insert the row with that id, into table2.
and i have to do this for all the entries in table1.
i have to update the row in table2 if it already exists, else insert new row. i check for recent record based on the date column, time_date.
both the tables have same schema.any help would be great.!
thank you. -
i have two tables with same schema. i have to check table1 for any updates and insert the updates or the entire row into table2, only the most recently updated row.
so basically, table2 has the unique values from table1; for the duplicate entries in table1, there is only the most recent entry in table2.
i have tried to get the most recently updated id from table1:SELECT distinct id
FROM table1 order by time_date desc limit 1;now i need to use this id to get the other columns from table1 and insert the row with that id, into table2.
and i have to do this for all the entries in table1.
i have to update the row in table2 if it already exists, else insert new row. i check for recent record based on the date column, time_date.
both the tables have same schema.any help would be great.!
thank you.You have already posted this question in QA: How Do I Insert Only Recently Updated Row From Table1 To 2[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer