UPDATE (
	SELECT  A.idPolice,A.id AS idBeneficiaire,A.idAdherent,
		B.numeroAdherent,B.nom AS nomAdherent,B.prenoms prenomsAdherent,A.numeroBeneficiaire,A.nomBeneficiaire,A.prenomsBeneficiaire
	FROM beneficiaire A 
	INNER JOIN adherent B ON ((A.codeSociete=B.codeSociete) AND  (B.id=A.idAdherent) AND (B.idPolice=A.idPolice))
	INNER JOIN police C ON (C.id=A.idPolice)
	INNER JOIN clients t ON ((A.codeSociete=t.codeSociete) AND  (t.id=C.idClient))	
	INNER JOIN gc_assureur Gc ON (Gc.codeGcAssureur=C.codeGcAssureur)
	WHERE (A.idPolice>0) AND A.nomBeneficiaire NOT LIKE "%AVENANT%"
	AND (CASE WHEN 303 IS NULL THEN A.idPolice IS NOT NULL ELSE A.idPolice=303 END)  
	AND A.codeLienParente='A' 
)  B
INNER JOIN carteassure R ON ( (R.idBeneficiaire=B.idBeneficiaire) AND  (R.idAdherent=B.idAdherent) AND (B.idPolice=B.idPolice))
SET 
R.nomAdherent=B.nomAdherent,
R.prenomsAdherent=B.prenomsAdherent,
R.adherent=CONCAT(B.nomAdherent,' ',B.prenomsAdherent),
R.nomBeneficiaire=B.nomBeneficiaire,
R.prenomsBeneficiaire=B.prenomsBeneficiaire,
R.beneficiaire=CONCAT(B.nomBeneficiaire,' ',B.prenomsBeneficiaire);


SELECT 
	B.numeroAdherent,B.nom,B.prenoms,A.numeroBeneficiaire,A.nomBeneficiaire,A.prenomsBeneficiaire,
	R.nomAdherent,R.prenomsAdherent,R.adherent,R.nomBeneficiaire,R.prenomsBeneficiaire,R.beneficiaire
FROM beneficiaire A 
INNER JOIN adherent B ON ((A.codeSociete=B.codeSociete) AND  (B.id=A.idAdherent) AND (B.idPolice=A.idPolice))
INNER JOIN carteassure R ON ((R.codeSociete=B.codeSociete) AND  (R.idBeneficiaire=A.id) AND  (R.idAdherent=A.idAdherent) AND (B.idPolice=A.idPolice))
INNER JOIN police C ON (C.id=A.idPolice)
INNER JOIN clients t ON ((A.codeSociete=t.codeSociete) AND  (t.id=C.idClient))	
INNER JOIN gc_assureur Gc ON (Gc.codeGcAssureur=C.codeGcAssureur)
WHERE (A.idPolice>0) AND A.nomBeneficiaire NOT LIKE "%AVENANT%"
AND (CASE WHEN 76 IS NULL THEN A.idPolice IS NOT NULL ELSE A.idPolice=76 END)  
AND A.codeLienParente='A' AND A.numeroAdherent='00760006'	;


/*

UPDATE carteassure  R
INNER JOIN beneficiaire A ON ((R.codeSociete=A.codeSociete) AND  (R.idBeneficiaire=A.id) AND  (R.idAdherent=A.idAdherent) AND (R.idPolice=A.idPolice))
INNER JOIN adherent B ON ((A.codeSociete=B.codeSociete) AND  (B.id=A.idAdherent) AND (B.idPolice=A.idPolice))

INNER JOIN police C ON (C.id=A.idPolice)
INNER JOIN clients t ON ((A.codeSociete=t.codeSociete) AND  (t.id=C.idClient))	
INNER JOIN gc_assureur Gc ON (Gc.codeGcAssureur=C.codeGcAssureur)
SET 
-- B.nom=A.nomBeneficiaire,B.prenoms=A.prenomsBeneficiaire	
  R.nomAdherent=B.nom,
  R.prenomsAdherent=B.prenoms,
  R.adherent=CONCAT(B.nom,' ',B.prenoms),
  R.nomBeneficiaire=A.nomBeneficiaire,
  R.prenomsBeneficiaire=A.prenomsBeneficiaire,
  R.beneficiaire=CONCAT(A.nomBeneficiaire,' ',A.prenomsBeneficiaire)
WHERE (A.idPolice>0) AND A.nomBeneficiaire NOT LIKE "%AVENANT%"
AND (CASE WHEN 76 IS NULL THEN A.idPolice IS NOT NULL ELSE A.idPolice=76 END)  
AND A.codeLienParente='A' AND A.numeroAdherent='00760006'	;
*/