February 4, 2011 at 7:07 am
Hello,
I have a table TB_Constante who contains:
ID CATEGORY Description
1STATUS Vide
2STATUS Pleine
3STATUS ½ pleine
4CONTENU Vidange
5CONTENU Transferts
6CONTENU Voyage Gaspésie
7CONTENU Voyage Côte-Nord
8CONTENU Voyage Fermont
9CONTENU Livraison
10CONTENU Autres
11EXCEPTIONErreur
12EXCEPTIONAvertissement
Another table (TB_tagLocation) with the following:
ID IDStatus IDContenu
31312011-02-02 07:57:12.12029NULLTrue
Fields IDStatus and IDContenu are FK to the table TB_Constante.
I'm doing a query that will get the Description field of those 2 FK (in this case, would be "Pleine" and "Livraison")
So far, I have:
SELECT TruckNoUnite,
cntDesc,
locdesc,
tranom,
cntDesc
FROM TB_inOUt
INNER JOIN TB_idtruck ON TB_idtruck.idtruck = TB_INOUT.idtruck
INNER JOIN TB_tagLocation ON TB_INOUT.idtruck = TB_tagLocation.idtruck
INNER JOIN TB_cntConstante ON TB_cntConstante.cntID = TB_taglocation.idstatus
INNER JOIN TB_locLocations ON TB_taglocation.locid = TB_locLocations.locid
inner join TB_traTransporteurs on TB_idtruck.traID = TB_traTransporteurs.traid
WHERE ioDateHeureSortie IS NULL
group by tranom ,locdesc,cntdesc,TruckNoUnite
I need to add a reference to IDContenu.
How i can do this???
thanks for your time and help
February 4, 2011 at 9:39 am
got the answer. query would be:
SELECT TruckNoUnite,
locdesc,
tranom,
c1.cntDesc,
c2.cntDesc
FROM TB_inOUt
INNER JOIN TB_idtruck ON TB_idtruck.idtruck = TB_INOUT.idtruck
INNER JOIN TB_tagLocation ON TB_INOUT.idtruck = TB_tagLocation.idtruck
INNER JOIN TB_cntConstante ON TB_cntConstante.cntID = TB_taglocation.idstatus
INNER JOIN TB_locLocations ON TB_taglocation.locid = TB_locLocations.locid
inner join TB_traTransporteurs on TB_idtruck.traID = TB_traTransporteurs.traid
INNER JOIN TB_cntConstante c1 on c1.cntID = dbo.TB_tagLocation.idStatus
INNER JOIN TB_cntConstante c2 on c2.cntID = dbo.TB_tagLocation.idContenu
WHERE ioDateHeureSortie IS NULL
group by tranom ,locdesc, c1.cntDesc, c2.cntDesc, TruckNoUnite
works fine that way.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply