1146 : INSERT INTO gene_2167321723_desc_cles
SELECT
a.id_indi
, case when b.id_wife is not NULL then b.id_wife when c.id_husb is not NULL then c.id_husb end
, case when b.id_wife is not NULL then b.date_evene when c.id_husb is not NULL then c.date_evene end
, case when b.id_wife is not NULL then b.lieu_evene when c.id_husb is not NULL then c.lieu_evene end
, case when b.id_wife is not NULL then b.dept_evene when c.id_husb is not NULL then c.dept_evene end
, a.id_pere
,if (a.id_indi != @old, 'O', 'N')
,@old := a.id_indi
FROM `gene_sds-full_individu` a
LEFT OUTER JOIN `gene_sds-full_evenement` b ON (a.id_indi = b.id_husb and b.type_evene = 'MARR')
LEFT OUTER JOIN `gene_sds-full_evenement` c ON (a.id_indi = c.id_wife and c.type_evene = 'MARR')
where a.id_pere IN (4139,3531,3384,3382,3720,4665,6538,3529,3658,3686,3710,4670,3430,3826,5564,3748,3381,6136,6488,5783,3885,3414,3690,3972,3666,4536,4088,4091,4148,5879,6559,4204,4216,3592,5321,6290,5391,4473,4539,4147,4293,6340,4592,4659,4830,4831,4882,4922,5025,5034,4476,5038,3495,5137,5168,5433,6053,4223,6569,3588,4571,5320,4224,5591,6548,5655,5045,5856,5951,5421,5937,5985,6067,5984,6057,4233,5510,4298,6237,6318,4499,6426,6443,6442,6566 )
and if (a.id_indi != @old, 'O', 'N') = 'O'
UNION ALL
SELECT
a.id_indi
, case when b.id_wife is not NULL then b.id_wife when c.id_husb is not NULL then c.id_husb end
, case when b.id_wife is not NULL then b.date_evene when c.id_husb is not NULL then c.date_evene end
, case when b.id_wife is not NULL then b.lieu_evene when c.id_husb is not NULL then c.lieu_evene end
, case when b.id_wife is not NULL then b.dept_evene when c.id_husb is not NULL then c.dept_evene end
, a.id_mere
,if (a.id_indi != @old, 'O', 'N')
,@old := a.id_indi
FROM `gene_sds-full_individu` a
LEFT OUTER JOIN `gene_sds-full_evenement` b ON (a.id_indi = b.id_husb and b.type_evene = 'MARR')
LEFT OUTER JOIN `gene_sds-full_evenement` c ON (a.id_indi = c.id_wife and c.type_evene = 'MARR')
where a.id_mere IN (4139,3531,3384,3382,3720,4665,6538,3529,3658,3686,3710,4670,3430,3826,5564,3748,3381,6136,6488,5783,3885,3414,3690,3972,3666,4536,4088,4091,4148,5879,6559,4204,4216,3592,5321,6290,5391,4473,4539,4147,4293,6340,4592,4659,4830,4831,4882,4922,5025,5034,4476,5038,3495,5137,5168,5433,6053,4223,6569,3588,4571,5320,4224,5591,6548,5655,5045,5856,5951,5421,5937,5985,6067,5984,6057,4233,5510,4298,6237,6318,4499,6426,6443,6442,6566 )
and if (a.id_indi != @old, 'O', 'N') = 'O'
1146 : SELECT
a.id_indi
,b.nom
,b.prenom1
,b.prenom2
,b.prenom3
,b.sexe
,b.profession
,b.date_naiss
,b.lieu_naiss
,b.dept_naiss
,b.date_deces
,b.lieu_deces
,b.dept_deces
,a.id_parent
,b.sosa_dyn
,a.id_conj
,a.date_maria
,a.lieu_maria
,a.dept_maria
,c.nom
,c.prenom1
,c.prenom2
,c.prenom3
,c.sexe
,c.sosa_dyn
,b.tri
,b.nickname
,b.titre
,b.etiquette
FROM gene_2167321723_desc_cles a
INNER JOIN `gene_sds-full_individu` b ON (a.id_indi = b.id_indi)
LEFT OUTER JOIN `gene_sds-full_individu` c ON (a.id_conj = c.id_indi)
ORDER BY a.id_parent, b.tri