Corrected query for select and add lastInsertId for answers table