olivthill | Il me semble que l'on peut s'en sortir avec des requêtes ordinaires, mais peut-être qu'il y a une difficulté cachée que je n'ai pas vue.
SELECT ST.IdObject, ST.IdObjEns, ST.Position, ST.Type
FROM SDL_ObjText AS ST, SDL_Objectif AS SO
WHERE ST.IdObject = SO.IdObject;
|
SELECT SI.IdObject, SI.IdObjEns, SI.Position, SI.Type
FROM SDL_ObjImg AS SI, SDL_Objectif AS SO
WHERE SI.IdObject = SO.IdObject;
|
Si l'on ne veut que les enregirstrement ayant des IdObjets commun aux trois tables, il suffit de rajouter une condition à chaque requête :
SELECT ST.IdObject, ST.IdObjEns, ST.Position, ST.Type
FROM SDL_ObjText AS ST, SDL_Objectif AS SO, SDL_ObjImg AS SI
WHERE ST.IdObject = SO.IdObject
AND ST.IdObject = SI.IdObject;
|
SELECT SI.IdObject, SI.IdObjEns, SI.Position, SI.Type
FROM SDL_ObjImg AS SI, SDL_Objectif AS SO, SDL_ObjText AS ST
WHERE SI.IdObject = SO.IdObject;
AND SI.IdObject = ST.IdObject;
|
Si l'on veut combiner les deux requêtes, on peut utiliser UNION :
SELECT ST.IdObject, ST.IdObjEns, ST.Position, ST.Type
FROM SDL_ObjText AS ST, SDL_Objectif AS SO
WHERE ST.IdObject = SO.IdObject
UNION
SELECT SI.IdObject, SI.IdObjEns, SI.Position, SI.Type
FROM SDL_ObjImg AS SI, SDL_Objectif AS SO
WHERE SI.IdObject = SO.IdObject;
|
Si on veut faire des additions, on utilisera SUM et GROUP BY. Message édité par olivthill le 13-04-2006 à 22:55:42
|