query duurt te lang

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ventilatiesysteem Productontwikkelaar HBO WO Verwa

Samengevat: Zij bieden flexibele ventilatiematerialen, geluidsdempers, rookgasafvoer producten en industrieslangen. Ben jij een technisch productontwikkelaar? Heb jij ervaring met het ontwikkelen van nieuwe producten? Vaste baan: Technisch Productontwikkelaar HBO WO €3.000 - €4.000 Zij bieden een variëteit aan flexibele ventilatiematerialen, geluiddempers, rookgasafvoer producten, industrieslangen en ventilatieslangen voor de scheepsbouw. Met slimme en innovatieve materialen zorgen wij voor een gezonde en frisse leefomgeving. Deze werkgever is een organisatie die volop in ontwikkeling is met hardwerkende collega's. Dit geeft goede ontwikkelingsmogelijkheden. De branche van dit bedrijf is Techniek en Engineering. Functie: Voor de vacature als Technisch Productontwikkelaar Ede Gld HBO WO ga

Bekijk vacature »

Daniyal hussain

daniyal hussain

06/05/2013 15:48:26
Quote Anchor link
hallo,
ik heb een query, maar die laadt veel te lang en ik zie geen fouten. Kunnen jullie mij hiermee helpen?

Quote:
SELECT
tabletreeproductgroup.STR_LEVEL,
case
when tabletreeproductgroup.STR_LEVEL=1 then tabletreeproductgroup.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=2 then tabletreeproductgroup2.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=3 then tabletreeproductgroup3.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup4.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup5.STR_TEXT else null
end,
case
when tabletreeproductgroup.STR_LEVEL=1 then tabletreeproductgroup.STR_ID
when tabletreeproductgroup.STR_LEVEL=2 then tabletreeproductgroup2.STR_ID
when tabletreeproductgroup.STR_LEVEL=3 then tabletreeproductgroup3.STR_ID
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup4.STR_ID
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup5.STR_ID else null
end,
/* -------------------------------- */
case
when tabletreeproductgroup.STR_LEVEL=2 then tabletreeproductgroup.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=3 then tabletreeproductgroup2.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup3.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup4.STR_TEXT else null
end,
case
when tabletreeproductgroup.STR_LEVEL=2 then tabletreeproductgroup.STR_ID
when tabletreeproductgroup.STR_LEVEL=3 then tabletreeproductgroup2.STR_ID
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup3.STR_ID
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup4.STR_ID else null
end,
/* -------------------------------- */
case
when tabletreeproductgroup.STR_LEVEL=3 then tabletreeproductgroup.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup2.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup3.STR_TEXT else null
end,
case
when tabletreeproductgroup.STR_LEVEL=3 then tabletreeproductgroup.STR_ID
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup2.STR_ID
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup3.STR_ID else null
end,
/* -------------------------------- */
case
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup.STR_TEXT
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup2.STR_TEXT else null
end,
case
when tabletreeproductgroup.STR_LEVEL=4 then tabletreeproductgroup.STR_ID
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup2.STR_ID else null
end,
/* -------------------------------- */
case
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup.STR_TEXT else null
end,
case
when tabletreeproductgroup.STR_LEVEL=5 then tabletreeproductgroup.STR_ID else null
end
FROM
`tabletreeproductgroup`
INNER JOIN tablelinkgroupscarsandparts ON (tabletreeproductgroup.STR_ID=tablelinkgroupscarsandparts.LGS_STR_ID)
INNER JOIN linkedtablecars ON (linkedtablecars.LAT_GA_ID=tablelinkgroupscarsandparts.LGS_GA_ID)
/* -------------------------------- */
LEFT JOIN tabletreeproductgroup AS tabletreeproductgroup2 ON (tabletreeproductgroup2.STR_ID = tabletreeproductgroup.STR_ID_PARENT)
INNER JOIN tablelinkgroupscarsandparts AS tablelinkgroupscarsandparts2 ON (tabletreeproductgroup2.STR_ID=tablelinkgroupscarsandparts2.LGS_STR_ID)
INNER JOIN linkedtablecars AS linkedtablecars2 ON (linkedtablecars2.LAT_GA_ID=tablelinkgroupscarsandparts2.LGS_GA_ID)
/* -------------------------------- */
LEFT JOIN tabletreeproductgroup AS tabletreeproductgroup3 ON (tabletreeproductgroup3.STR_ID = tabletreeproductgroup2.STR_ID_PARENT)
INNER JOIN tablelinkgroupscarsandparts AS tablelinkgroupscarsandparts3 ON (tabletreeproductgroup3.STR_ID=tablelinkgroupscarsandparts3.LGS_STR_ID)
INNER JOIN linkedtablecars AS linkedtablecars3 ON (linkedtablecars3.LAT_GA_ID=tablelinkgroupscarsandparts3.LGS_GA_ID)
/* -------------------------------- */
LEFT JOIN tabletreeproductgroup AS tabletreeproductgroup4 ON (tabletreeproductgroup4.STR_ID = tabletreeproductgroup3.STR_ID_PARENT)
INNER JOIN tablelinkgroupscarsandparts AS tablelinkgroupscarsandparts4 ON (tabletreeproductgroup4.STR_ID=tablelinkgroupscarsandparts4.LGS_STR_ID)
INNER JOIN linkedtablecars AS linkedtablecars4 ON (linkedtablecars4.LAT_GA_ID=tablelinkgroupscarsandparts4.LGS_GA_ID)
/* -------------------------------- */
LEFT JOIN tabletreeproductgroup AS tabletreeproductgroup5 ON (tabletreeproductgroup5.STR_ID = tabletreeproductgroup4.STR_ID_PARENT)
INNER JOIN tablelinkgroupscarsandparts AS tablelinkgroupscarsandparts5 ON (tabletreeproductgroup5.STR_ID=tablelinkgroupscarsandparts5.LGS_STR_ID)
INNER JOIN linkedtablecars AS linkedtablecars5 ON (linkedtablecars5.LAT_GA_ID=tablelinkgroupscarsandparts5.LGS_GA_ID)
/* -------------------------------- */
WHERE
linkedtablecars.LAT_TYP_ID='$selectedtype' AND
linkedtablecars2.LAT_TYP_ID='$selectedtype' AND
linkedtablecars3.LAT_TYP_ID='$selectedtype' AND
linkedtablecars4.LAT_TYP_ID='$selectedtype' AND
linkedtablecars5.LAT_TYP_ID='$selectedtype'
GROUP BY
tabletreeproductgroup.STR_LEVEL,
tabletreeproductgroup.STR_TEXT,
tabletreeproductgroup.STR_ID,
tabletreeproductgroup2.STR_TEXT,
tabletreeproductgroup2.STR_ID,
tabletreeproductgroup3.STR_TEXT,
tabletreeproductgroup3.STR_ID,
tabletreeproductgroup4.STR_TEXT,
tabletreeproductgroup4.STR_ID,
tabletreeproductgroup5.STR_TEXT,
tabletreeproductgroup5.STR_ID
ORDER BY
tabletreeproductgroup.STR_TEXT,
tabletreeproductgroup2.STR_TEXT,
tabletreeproductgroup3.STR_TEXT,
tabletreeproductgroup4.STR_TEXT,
tabletreeproductgroup5.STR_TEXT
 
PHP hulp

PHP hulp

26/04/2024 11:22:14
 
Ger van Steenderen
Tutorial mod

Ger van Steenderen

06/05/2013 18:24:05
Quote Anchor link
Je geeft je case statements geen aliassen, en je gebruikt een group by zonder aggerate functie(s)
Je hebt (even snel geteld) ca 16 joins, dit betekent dat mysql gaat werken het totaal aantal kolommen van de tabellen die in die joins voorkomen (ook al is het telkens dezelfde tabel).

Waarom heb je die auto gegevens nodig als je een tree aan het opbouwen bent?
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.