select last row in database and start inserting after it code example Example: mysql get last row SELECT fields FROM table ORDER BY id DESC LIMIT 1;