Error database

  
Hi
how can i avoid this data base error  
cheers
Show the real query please
J. wrote:
Show the real query please
 select {Consomation1}.[Kilometrage_heur],{Consomation1}.[Date_Kilometrage],{OperationsEntretienVC}.[designation],{Engins}.[Num_Ordre],{Engins}.[Marque]
,
( select sum ({Activites}.[MainOeuvreRep]) 
from {Activites}
     where {Activites}.[EntretienVcID]={Consomation1}.[Id]
) total_mainoeuvre
,
 (
 select sum({Entretien_Item_VC}.[Prix_Total]) 
from {Entretien_Item_VC}
where {Consomation1}.[Id]={Entretien_Item_VC}.[EntretienID] )

from {Consomation1}
join {OperationsEntretienVC} on {OperationsEntretienVC}.[Id]={Consomation1}.[OperationEntretienID]
left join {Consomation1} on {Consomation1}.[EnginID]={Engins}.[Id]

 order by {Consomation1}.[Id]
 
 
I see,

In the last part you do a {Consomation1} left join {Consomation1}, which the compiler/sql gets weird about, because it cannot determine which one to use.
furthermore I don;t see any engins as well, so my "guess" is, it should be 

from {Consomation1}
join {OperationsEntretienVC} on {OperationsEntretienVC}.[Id]={Consomation1}.[OperationEntretienID]
left join {Engins} on {Consomation1}.[EnginID]={Engins}.[Id]

if that is not the case, and you really need to join the same table, then you need to give them aliases.

something like {Consomation1} consThis and {Consomation1} consOther
and then you use them in the assignments, like consOther.[EnginID] = {Engins}.[Id]


J. wrote:
I see,

In the last part you do a {Consomation1} left join {Consomation1}, which the compiler/sql gets weird about, because it cannot determine which one to use.
furthermore I don;t see any engins as well, so my "guess" is, it should be 

from {Consomation1}
join {OperationsEntretienVC} on {OperationsEntretienVC}.[Id]={Consomation1}.[OperationEntretienID]
left join {Engins} on {Consomation1}.[EnginID]={Engins}.[Id]

if that is not the case, and you really need to join the same table, then you need to give them aliases.

something like {Consomation1} consThis and {Consomation1} consOther
and then you use them in the assignments, like consOther.[EnginID] = {Engins}.[Id]

 
 Hi
It's done, thank you

best cheers