Requête update avec inner join
bonjour,
j'essaye d’écrire une requête assez compliquée et je n'arrive pas à trouver la bonne syntaxe.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
update enfantcartes
INNER JOIN ( SELECT enfantcartes.carteid from ( SELECT enfantid, 'EF'+ RIGHT('000000' + CONVERT(enfantid,CHAR),6) as carte,
'99'+ RIGHT('000000' + CONVERT(enfantid,CHAR),6) as carteerreur FROM (SELECT enfantid from enfantaccueil
inner join accueil ON enfantaccueil.accueilid = accueil.accueilid where accueil.annee = 2012 AND LEFT(accueil.typestructure,4) = 'ALSH'
GROUP BY enfantid) A ) B
ON enfantcartes.enfantid = B.enfantid AND enfantcartes.carte = B.carte where automatique <> 0 and datefin is not null)
set datefin = null
where carteid in ( SELECT enfantcartes.carteid from ( SELECT enfantid, 'EF'+ RIGHT('000000' + CONVERT(enfantid,CHAR),6) as carte,
'99'+ RIGHT('000000' + CONVERT(enfantid,CHAR),6) as carteerreur FROM (SELECT enfantid from enfantaccueil
inner join accueil ON enfantaccueil.accueilid = accueil.accueilid where accueil.annee = 2012 AND LEFT(accueil.typestructure,4) = 'ALSH'
GROUP BY enfantid) ) |
Comme vous pouvez le voir, j'ai beaucoup de requêtes select imbriquées dans ma requête update et j'avoue que j'ai un peu du mal à trouver la bonne syntaxe
Merci d'avance