
-- 1 -- pOUR CONSULTER
SELECT DISTINCT ca.*
FROM beneficiaire b 
INNER JOIN adherent a ON (a.id=b.idAdherent)
LEFT JOIN beneficiaireprime r ON (b.id=r.idBeneficiaire)
LEFT JOIN garantieadherent ga ON (a.id=ga.idAdherent)  
LEFT JOIN limitebeneficiaire lb ON (b.id=lb.idBeneficiaire)   
LEFT JOIN limiteadherent la  ON (a.id=la.idAdherent)
LEFT JOIN carteassure ca ON (b.id=ca.idBeneficiaire) 
-- WHERE  a.numeroAdherent IN ("03460008","03460005","03460001","03460003");  -- POUR LES ADHERENTS
WHERE a.id>0 AND b.numeroBeneficiaire IN ('0257004201','0257004301');   -- POUR LES BENEFICIAIRES


-- 2-- SUPPRESSION


-- 1 -- pOUR CONSULTER
DELETE r,b,a,ga,lb,la,ca
FROM beneficiaire b 
INNER JOIN adherent a ON (a.id=b.idAdherent)
LEFT JOIN beneficiaireprime r ON (b.id=r.idBeneficiaire)
LEFT JOIN garantieadherent ga ON (a.id=ga.idAdherent)  
LEFT JOIN limitebeneficiaire lb ON (b.id=lb.idBeneficiaire)   
LEFT JOIN limiteadherent la  ON (a.id=la.idAdherent)
LEFT JOIN carteassure ca ON (b.id=ca.idBeneficiaire) 
-- WHERE  a.numeroAdherent IN ("03460008","03460005","03460001","03460003");  -- POUR LES ADHERENTS
WHERE a.id>0 AND b.numeroBeneficiaire IN ('0257004201','0257004301');   -- POUR LES BENEFICIAIRES





DELETE r,b,a,ga,lb,la FROM beneficiaireprime r,beneficiaire b,adherent a
,garantieadherent ga,limitebeneficiaire lb,limiteadherent la  
WHERE (b.id=r.idBeneficiaire)
AND (a.id=b.idAdherent)
AND (a.id=ga.idAdherent)
AND (a.id=la.idAdherent)
AND (b.id=lb.idBeneficiaire)
-- AND a.numeroAdherent IN ("03081782","03081792");  -- POUR LES ADHERENTS
AND b.numeroBeneficiaire IN ('0308194506');   -- POUR LES BENEFICIAIRES





SELECT * FROM limitebeneficiaire
WHERE numeroAdherent IN ("03080314",'03081530','03081230','03081218','03081217','03081216');


SELECT * FROM emission
