0
Good evening, I have an SQL table in which I will put movie recommendations by users, but I want when it reaches a total of records in this table, it deletes the older records.
My code is like this:
$sql = "INSERT INTO filmes_rec (filmes)
VALUES ('$recomendacao')";
if($link->query($sql) === TRUE) {
echo 'Obrigado por compartilhar seu gosto com a gente, você recomendou:<br>';
echo '<p class="strong"><strong>';
echo $recomendacao;
echo '</strong></p>';
} else {
echo "Error creating new record";
}
DBMS was not specified but other solutions would be TRIGGER or a scheduling process (jog , Event etc) but these solutions depend on BD.
– Motta
I don’t want to delimit lines in the database, I just want to do that when it gets to a specific number of lines, it deletes some records from the table.
– Luvinicius
I don’t understand. You need that when the table reaches 51 lines, it erases the oldest value to get only the 50 newest ones is not?
– jpenna