7
I’d like to delete several figures. For example this would be to delete a line
delete from paginasimagens where idPaginasImagens=121;
my values are sequentially so a method that is between elements serves;
7
I’d like to delete several figures. For example this would be to delete a line
delete from paginasimagens where idPaginasImagens=121;
my values are sequentially so a method that is between elements serves;
11
If you will manually type the Ids:
delete from paginasimagens where idPaginasImagens in (121, 122, 123)
If Ids come from a query:
delete from paginasimagens where idPaginasImagens in (SELECT idPaginasImagens FROM outraTabela)
If you want to delete a sequence of Ids:
delete from paginasimagens where idPaginasImagens between 1 and 30
In my opinion, this is the most appropriate answer to the user’s doubt.
7
Use the operator BETWEEN
to obtain the desired result, using the first value (which will be included in the exclusion) and the last value (which will also be deleted):
DELETE FROM paginasimagens
WHERE idPaginasImagens BETWEEN 121 AND 123;
If
expr
is Greater than or Equal to min andexpr
is Less than or Equal to max,BETWEEN
Returns 1, otherwise it Returns 0.
In free translation:
If
expr
is greater than or equal to the minimum andexpr
is less than or equal to the maximum,BETWEEN
return 1, or return 0.
1
To delete all table data also, with TRUNCATE
:
TRUNCATE TABLE paginasimagens;
Even if formatting the server usually erases the lines together
@Sorack hardware alternative https://imgur.com/j0MqK4e
@Bacco justo hahaha
-6
Utilizes the checkbox in your table name="item[]"
in PHP creates a loop with foreach
:
foreach($_POST['item'] as $item) {
$sql("delete from paginasimagens WHERE id = '$item'");<br>
$sql = $conexao->query($sql) or die($conexao->error);
}
Browser other questions tagged mysql sql database delete
You are not signed in. Login or sign up in order to post.
you can use a
where coluna in (1,2,3)
orwhere coluna between 1 and 30
– Bulfaitelo
There are some techniques described in Delete row set in huge tables -> https://portosql.wordpress.com/2019/10/16/delete-vlt/
– José Diz