Delete and / or update data massively [closed]

-2

How can I remove data massively from my database (since I need to delete more than 10 thousand data that are stored, and then delete the data one by one would not be appropriate)

Basic Consultation

$deletePersona = "DELETE FROM persona 
                  WHERE id_persona = '$id_persona'"

You must delete the data with user type "Visitor = 4", which have a date range.

SELECT * FROM 'persona' WHERE id_tipoUsuario = '4' 
    
asked by jecorrales 07.11.2017 в 17:09
source

2 answers

2

Analyze your information universe, in which you must find a particular field that shares the records with each other; for example: We want to delete the records of the people in the department 'Loading area'.

$deletePersona = "DELETE FROM persona 
              WHERE departamento = 'Área de carga'"

Either combine them with another condition, when the person is from the 'Loading Area' and their age is greater than or equal to '22'

$deletePersona = "DELETE FROM persona 
              WHERE departamento = 'Área de carga' AND edad >= '22'"
    
answered by 07.11.2017 / 17:31
source
-2

Well, you have several options depending on which one fits your problem better, for example:

while($id_persona)
    $deletePersona = "DELETE FROM persona 
                      WHERE id_persona = '$id_persona[$i]'"
                      $i++

Where you should go through the arrangement where you have the person id you want to delete from.

If you want to erase everything, it would be enough with:

    $deletePersona = "DELETE FROM persona"

Another option is to concatenate all ids separated by commas:

    $deletePersona = "DELETE FROM persona 
                      WHERE id_persona IN (5,6,8,9,...)"
    
answered by 07.11.2017 в 17:27