SELECT * FROM beneficiaire
WHERE codeEtatBeneficiaire="SP"
AND sorti=1



UPDATE beneficiaire
SET dateSortie=(NULL),sorti=0,dateEntree=dateEffet
WHERE codeEtatBeneficiaire="SP"
AND sorti=1