bonjour,
j'ai la requête suivante qui me permet de rechercher des enregistrements liés et de ressortir les id dont j'ai besoin pour faire un update.
J'obtiens le résultat suivant avec 3 colonnes contenant chacune les id :SELECT t1.ged_struct_id, t2.ged_struct_id, t3.ged_struct_id
FROM `da_ged_struct` AS t1
INNER JOIN da_ged_struct AS t2 ON t2.ged_struct_parent = t1.ged_struct_id
INNER JOIN da_ged_struct AS t3 ON t3.ged_struct_parent = t2.ged_struct_id
WHERE t1.ged_struct_parent = '391599'
ged_struct_id ged_struct_id ged_struct_id
391600 391601 762555
391600 391601 774527
391600 391601 882974
391600 391601 986461
391600 391601 1090132
391600 391602 765548
391600 391602 777520
391600 391602 885988
391600 391603 768541
391600 391603 780513
391600 391603 889002
391600 391604 771534
391600 391604 783506
391600 391604 901058
391600 867903 870917
391600 867903 873931
391600 867903 879959
391600 867903 895030
391600 1173075 1176395
391600 1173075 1179715
391600 1173075 1183035
391600 1173075 1186355
391600 1173075 1189675
391600 2483318 2491132
391600 2483318 2498946
391600 2483318 2506760
391600 2483318 2514574
391600 2483318 2522388
391605 746833 746835
391605 746833 746839
Je souhaiterais obtenir non pas 3 colonnes mais une seule colonne contenant les id sans doublons.
J'ai essayé la chose suivante avec un distinct mais ça ne marche pas.
SELECT DISTINCT(t1.ged_struct_id, t2.ged_struct_id, t3.ged_struct_id) AS ged_struct_id
FROM `da_ged_struct` AS t1
INNER JOIN da_ged_struct AS t2 ON t2.ged_struct_parent = t1.ged_struct_id
INNER JOIN da_ged_struct AS t3 ON t3.ged_struct_parent = t2.ged_struct_id
WHERE t1.ged_struct_parent = '391599'
Partager